I have a GridView with BoundColumns. The first 2 columns are hidden and I would like to access them using gridView1.Rows[0].Cells[0].Text and gridView1.Rows[0].Cells[1].Text respectively and I get a empty string. When the columns are changed to visible, then I can access the values. I have tried changing the column width to zero as suggested on some other forums but that never fixed the problem. Does any one have any pointers as to what I may be doing wrong.
Share
If the Columns are part of the
DataKeyNamescollection, then you should get their values from theGridView.DataKeys[index].valueproperty, as demonstrated on the GridViewGuy site.If however, they are not part of the
DataKeyNamescollection, then you can use the following hack to make sure that the value is persisted in ViewState (as opposed to normal behaviour for hidden fields in ASP.NET 2+)