Hi kishore21,
I have created a sample which full fill your requirement you need to modify it according to your need
HTML
<div>
<asp:GridView ID="gvDetails" runat="server" OnRowDataBound="gvDetails_RowDataBound" />
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Name"), new DataColumn("Age"), new DataColumn("DOB"), new DataColumn("PhoneNumber") });
dt.Rows.Add("John Hammond", 20, "1996/31/05", 9852456334);
dt.Rows.Add("Mudassar Khan", 25, "1990/25/01", 9684326445);
dt.Rows.Add("Suzanne Mathews", 35, "1980/10/02", 978726412);
dt.Rows.Add("Robert Schidner", 40, "1975/20/03", 9875262456);
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[3].Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[3].Visible = false;
}
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Name"), New DataColumn("Age"), New DataColumn("DOB"), New DataColumn("PhoneNumber")})
dt.Rows.Add("John Hammond", 20, "1996/31/05", 9852456334L)
dt.Rows.Add("Mudassar Khan", 25, "1990/25/01", 9684326445L)
dt.Rows.Add("Suzanne Mathews", 35, "1980/10/02", 978726412)
dt.Rows.Add("Robert Schidner", 40, "1975/20/03", 9875262456L)
gvDetails.DataSource = dt
gvDetails.DataBind()
End If
End Sub
Protected Sub gvDetails_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells(3).Visible = False
End If
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(3).Visible = False
End If
End Sub
Output
Name |
Age |
DOB |
John Hammond |
20 |
1996/31/05 |
Mudassar Khan |
25 |
1990/25/01 |
Suzanne Mathews |
35 |
10/2/1980 |
Robert Schidner |
40 |
1975/20/03 |