is it possible inside the gridview events for commands to find a cell by datafield name or headertext name when using boundcolumns?
views:
55answers:
1
+1
A:
you can find a column in GridView.Columns and then use its index to find a desired cell. Something like in this example:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
var myColumn = GridView1.Columns.Cast<DataControlField>().First(c => c.HeaderText == "MyColumn");
var row = GridView1.Rows[int.Parse(e.CommandArgument.ToString())];
var cell = row.Cells[GridView1.Columns.IndexOf(myColumn)];
}
dh
2010-02-09 13:15:01