In this article I will explain how to find controls (textbox, dropdownlist, checkbox,radio button etc..) in inside of gridview and how to get values from controls which is inside of gridview in rowdatabound condition in asp.net.
In previous posts I explained many articles relating to gridview now I will explain how to find or get values of controls which is inside of gridview in asp.net.
protected void
gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddl = (DropDownList)gvUserInfo.FindControl("yourControlName");
string ddlValue = ddl.SelectedItem.Value;
TextBox txtUserInfo = (TextBox)
gvUserInfo.FindControl("yourControlName");
string strValue = txtUserInfo.Text;
}
|
protected
void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddl = (DropDownList)e.Row.FindControl("ddlCity");
int CountryId = Convert.ToInt32(ddl.SelectedItem);
}
}
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
7 comments :
nice
you are using dropdown list can u please show in gridview
great,, thanks,,,
work for me.. thanks a loott
sir can you provide a demo for nested gridview And load data into it from sql in C#?
thanks.Nice one
Hi suresh i want to find span id in row databond is it possible to find that
@Anonymous
You can get the span id in rowdatabound event by defining control there as HtmlGenericControl.
var spanid = e.item.FindControl("") as HtmlGenericControl