Dear Friends,
i have a Gridview in which there is particular Column name SrNo
my requirement is the SrNo should automacillay gets its series no
example for 1st row in gridview it should be P01
for second it will be P02 and so on.....
the users will manually enter the other details in Grid except SrNo.
how can i acheive this?
Regards,
aamir
Satyapriya NayakPosted Jul 5, 2012, 4:15 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Gridview.WebForm1" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Gridview
{
public partial class WebForm1 : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;
protected void Page_Load(object sender, EventArgs e)
{
bindgrid();
}
private void bindgrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from student";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
GridView1.DataMember = "student";
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
}
}
Thanks
If this post helps you mark it as answer