oDs.Tables(0).Columns("id").ColumnMapping = MappingType.Hidden GridView1.DataSource = oDs GridView1.DataBind()
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated For Each col As DataColumn In CType(GridView1.DataSource, _ DataSet).Tables(0).Columns If col.ColumnMapping = MappingType.Hidden Then e.Row.Cells(CType(GridView1.DataSource, _ DataSet).Tables(0).Columns.IndexOf(col.ColumnName) + 1) .Visible = False End If Next End Sub
Gridview1.Columns(1).Visible = False
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[index].Visible = false; }
foreach (DataColumn dc in oDs.Tables(0).Columns) { BoundColumn dgc = new BoundColumn(); dgc.HeaderText = dc.ColumnName; dgc.DataField = dc.ColumnName; if (dc.ColumnName.Contains("Id")) dgc.Visible = false; GridView1.Columns.Add(dgc); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)