TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhijit Chougule
NA
12
12.7k
asp.net cascading dropdown list data binding
Mar 10 2015 12:34 AM
I am trying to bind a drop downlist by selecting a country dropdownlist.On selected index changed of dropdoen list country,it should display the states belonging to that country.
I have written the code to bind the ddlstate as -------
protected void ddlcountry_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
int countryid = Convert .ToInt32(ddlcountry.SelectedValue);
//Select all States corresponding to the selected country
SqlDataAdapter adp = new SqlDataAdapter("select * from userstate where stid = " + countryid,con);
DataSet ds = new DataSet ();
adp.Fill(ds);
ddlstate.DataSource = ds;
ddlstate.DataTextField = "statename" ;
ddlstate.DataValueField = "statename" ;
ddlstate.DataBind();
ddlstate.Items.Insert(0, new ListItem ("--Select--" , "0" ));
}
catch ( Exception ex)
{
Response.Write( "Error occured : " + ex.Message.ToString());
}
finally
{
con.Close();
}
}
It is giving error as
Input string was not in a correct format.
Reply
Answers (
1
)
Display data with in grid
Want to send reminder mail from asp.net to outlook