We help IT Professionals succeed at work.

ASP.NET datagrid boundfield value

ksfok
ksfok asked
on
Medium Priority
877 Views
Last Modified: 2008-03-06
How can the value of a boundfield in a datafield be accessed in the datagrid 's itemcreated event? Please advise sample code. Thanks.
Comment
Watch Question

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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.