I have written a function called on change of a value in a dropdown box.
Here is the function:
protected void ddlDistrict_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
IApplicationContext ctx = ContextRegistry.GetContext();
IServices reg = (IServices)ctx.GetObject("Services");
if (ddlDistrict.SelectedIndex != 0)
{
Int32 DistrictID = Convert.ToInt32(ddlDistrict.SelectedValue);
ddlTaluka.DataSource = reg.getTalukaList(DistrictID));
ddlTaluka.DataTextField = "TalukaName";
ddlTaluka.DataValueField = "TalukaID";
ddlTaluka.DataBind();
ddlTaluka.Items.Clear();
ddlTaluka.Items.Insert(0, new ListItem("-- Select Taluka --", "0"));
}
else
{
ddlTaluka.Items.Clear();
ddlTaluka.Items.Insert(0,new ListItem("-- Select Taluka --", "0"));
}
}
catch (Exception ex)
{
}
}
On change of a value in district dropdown taluka dropdown should be refilled...but I am getting error
Input string was not in correct format
in this line
Int32 DistrictID = Convert.ToInt32(ddlDistrict.SelectedValue);
I am not understanding how to resolve this error.
ddlDistrict.SelectedValue? Hold your mouse over it; it will tell you. Then work your way back until you figure out why it is wrong.String.Splitusing';'as the delimiter.