ASP.NET datagrid boundfield value

How can the value of a boundfield in a datafield be accessed in the datagrid 's itemcreated event? Please advise sample code. Thanks.
ksfokAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sasapopovicConnect With a Mentor Commented:
Hi ksfok,

I did this for GridView but I assume it is the same with all other grid like controls.
What you need is to handle the RowDataBound event for your grid. Then in RowDataBound event handler you can cast e.Row.DataItem to class from collection bounded to the grid. For example:

void mygrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
   MyClass myInstance = (MyClass)e.Row.DataItem;
   //TODO: do something with myInstance
}

I hope this is what you need.

Regards,
Sasa
0
All Courses

From novice to tech pro — start learning today.