3
Going through the event RowDataBound
of a GridView
I intend to obtain the value of headertext
column but I’m not getting.
An example I want to get:
if (e.Row.RowType.ToString().Equals("Header"))
{
}
else if (e.Row.RowType == DataControlRowType.DataRow)
{
int tot = e.Row.Cells.Count;
for (int i = 1; i < tot; i++)
{
TextBox txtValor = new TextBox();
txtValor.Width = 15;
string produ = e.Row.Header.text //Preciso de obter o valor do titulo da coluna.
txtValor.Text = (e.Row.DataItem as DataRowView).Row[produ].ToString();
e.Row.Cells[i].Controls.Add(txtValor);
}
}
Returns empty, returns no value
– user6018
@user6018 I’ll assume you’re filling gridview through the database, maybe that’s why it’s appearing empty. I edited the answer with another solution.
– Omni