Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
5
Reply
HI. I trying to populate dropdownlist with values in the database in asp.net. But its not working:(
Deepali Patil
Oct 13 2012 3:53 AM
2.4k
Reply
Here is my code:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[0].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from Student1", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
drpdownlist.DataTextField = ds.Tables[0].Columns["FullName"].ToString();
drpdownlist.DataValueField = ds.Tables[0].Columns["Id"].ToString();
drpdownlist.DataSource = ds.Tables[0];
drpdownlist.DataBind();
Its giving problem for the first line.
Please help.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
adding namespace to datacontract results null value in WCF request
get value of gridview cell on button click