I have a gridview in my web form and I am using the following code in my web form. Save Button:
foreach (GridViewRow row in gvList.Rows) if (row.RowType == DataControlRowType.DataRow) { for (int i = 0; i < row.Cells.Count; i++) { string headerRowText = ???;
How to get the current text of the cell header.
I solved this using:
string headerRowText = gvList.HeaderRow.Cells[i].Text;
gvList.Rows [0] should be your title bar. You should be able to get
gvList.Rows[0].Cells[i]
It is just to get a cage. You will need to enter the cell and get Controls [0] and apply it to the appropriate type, and then get the Text property.
returned an empty string for me that the work was:
GridView1.Columns[i].HeaderText
Set property GridView UseAccessibleHeaderText=true
UseAccessibleHeaderText=true
Then, when encoding the code, to use the j-th column:
GridView1.HeaderRow.Cells[0].Text