Before rendering the gridview control, each row in the control must be bound to a record in the data source. When you bind a data row (represented by a gridviewrow object) to the data in the gridview control, the rowdatabound event is triggered. This allows you to provide an event processing method, that is, a custom routine is executed every time this event occurs (such as modifying the value of the data bound to the row ).
The gridviewroweventargs object is passed to the event processing method so that you can access the attributes of the row being bound. To access a specific cell in the row, use the cells attribute of the gridviewroweventargs object. You can use the rowtype attribute to determine which row type is being bound (header row, data row, and so on ).
Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
{
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
Label lblname = (Label) E. Row. findcontrol ("lblname ");
Label lblmoney = (Label) E. Row. findcontrol ("lblmoney ");
Label lblzdot = (Label) E. Row. findcontrol ("lblzdot ");
Label lblsdot = (Label) E. Row. findcontrol ("lblsdot ");
Profilecommon P = profile. getprofile (lblname. Text );
Lblmoney. Text = P. inmoney. tostring ();
Lblzdot. Text = P. dcount. tostring ();
Lblsdot. Text = P. scount. tostring ();
}
}