the code is used is this ....plsss tell me the error in this...
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
int countryId = int.Parse(DropDownList1.SelectedIndex.ToString ());
DataTable dt = new DataTable();
dt = bindDropDown("select countryid,countryname from tblcountry where tblcountry.regionid =" + countryId );
DropDownList1.DataSource = dt;
DropDownList1.DataValueField = "countryid";
DropDownList1.DataTextField = "countryname";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
}
public DataTable bindDropDown(string query)
{
SqlDataAdapter dataAdapter = new SqlDataAdapter(query,con);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
return (dataSet.Tables[0]);
}
in the form load event
if (!IsPostBack)
{
DataTable dt1 = new DataTable();
dt1 = bindDropDown("select tblregion.regionid,tblregion.regionfullname from tblregion");
DropDownList2.DataSource = dt1;
DropDownList2.DataTextField = "regionfullname";
DropDownList2.DataValueField = "regionid";
DropDownList2.DataBind();
DropDownList2.Items.Insert(0, new ListItem("--Select--", "0"));
}