I have a GridView.
At event _RowDataBound I need take the underlying value from every single Field (ex let immagine FirstName), apply some logic to it, and display the field modify to a Textbox.
My problem is I do not the syntax to get the values connected with the e.Row.DataItmem for a single row.
Any idea how to do it? Please provide me an example of code. I posted this question in past but without understanding the answer. Thanks
switch (e.Row.RowType)
{
// In case type of row is DataRow (a data row of GridView)
case DataControlRowType.DataRow:
// What I add here?
break;
}
it depends on the property names of the object you used as the gridvieww datasource, so if you had a column named FirstName, you can access it like this:
a better approach i always use is to cast the DataItem object itself to my bound class. for example if the gridview datasource is a
List<Employee>, i do the following:then you can access all the properties using the item