6 March 2014

Get Find control inside of asp.net gridview in rowdatabound event

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddl = (DropDownList)e.Row.FindControl("ddlCity");
int CountryId = Convert.ToInt32(ddl.SelectedItem);
}
}

OR

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddl = (DropDownList)gvUserInfo.FindControl("ControlName");
string ddlValue = ddl.SelectedItem.Value;
TextBox txtUserInfo = (TextBox) gvUserInfo.FindControl("ControlName");
string strValue = txtUserInfo.Text;
}

No comments:

Post a Comment