Monday, December 19, 2011

Row Data Bound Event and how to use it

Row Data Bound Event and how to use it :


Control Used :Grid View 
Event Under Grid View :onrowdatabound







Event :
onrowdatabound="grdCompetitors_RowDataBound"
Function:

protected void grdCompetitors_RowDataBound(object sender, GridViewRowEventArgs e)
{

}
Details Used :
e.Row.RowType == DataControlRowType.DataRow  // For  DataRow
e.Row.RowType == DataControlRowType.EmptyDataRow // For  EmptyDataRow
e.Row.RowType == DataControlRowType.Footer // For  Footer
e.Row.RowType == DataControlRowType.Header // For Header
e.Row.RowType == DataControlRowType.Pager // For  Paging Template
e.Row.RowType == DataControlRowType.Separator  // For  Seperator


Capturing Data from Gridview:


e.Row.Cells[0].Text  // Enter cell id under cells and capture values


Use:
When we are using some logics or want to use null values that we encounter from sql database i recommend using row data bound event as it helps in giving logic to the grid view ....








No comments: