protected void GrdTabRow_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (((DropDownList)e.Row.FindControl("ddlCOuntry")).SelectedItem.Value != "Select")
BindDropdownWWC(((DropDownList)e.Row.FindControl("ddlState")), "select * from tblState where Category=" + ((DropDownList)e.Row.FindControl("ddlCountry")).SelectedItem.Value + "", "StateName", "StateID", "Select");
}
}
//Here BindDropdownWWC is the funtion to bind state
public void BindDropdownWWC(DropDownList ddl, string qryInput, string textField, string valueField, string zerothIndex)
{
try
{
SqlDataAdapter da = new SqlDataAdapter(qryInput, objDA.AccessConnection());
DataTable dt = new DataTable();
da.Fill(dt);
ddl.DataSource = dt;
ddl.DataTextField = textField;
ddl.DataValueField = valueField;
ddl.DataBind();
ddl.Items.Insert(0, zerothIndex);
}
catch (Exception ex)
{
throw ex;
}
}