Thursday, 16 May 2013

Code to Find Control Inside of Asp.Net Gridview in Rowdatabound event


Code to Find Control Inside of Asp.Net Gridview in Rowdatabound event

In this article i will tell you how to find control inside of asp.net gridview in rowdatabound event. This will cover find control in gridview rowdatabound, find control in gridview rowcommand event,find control in gridview row.

So for this article i will give you some example for finding textbox, dropdown, and checkboc control in gridview.

FOR TEXTBOX:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
TextBox txtname = (TextBox) gvUserInfo.FindControl("yourControlName");
string strnameValue = txtname.Text;
}


FOR DROPDOWN:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddlusercontrol = (DropDownList)gvUserInfo.FindControl("yourControlName");
string ddlselectedvalue = ddlusercontrol.SelectedItem.Value;
}


FOR CHECKBOX:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
CheckBox chkusercontrol = (CheckBox)gvUserInfo.FindControl("yourControlName");
string chkvalue = chkusercontrol.Value;
}


Thanks..

No comments:

Post a Comment