Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 2nd, 2012, 02:07 AM
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Lagos, Lagos, Nigeria.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dababy Send a message via Yahoo to dababy
Default Dropdown list not retrieving data from the database.

My code below does not display any err msg but it is not displaying the desired result. I am querying a database using a dropdown list control and I want the result to display on specified textboxes.

protected void stateList_SelectedIndexChanged(object sender, EventArgs e)

sqlquerypopulation.SelectCommandType = SqlDataSourceCommandType.Text;
String qry = "select Males,Females,Bothsexes,Landsize from Population where LGA = '"+ stateList.SelectedItem.Value.ToString()+"'";
System.Data.SqlClient.SqlConnection myCon = new System.Data.SqlClient.SqlConnection("server=BANCAS S\\SQLEXPRESS;database=Ruralconnect;uid=sa;pwd=");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(qry,myCon);
System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read()) {
txtpopulate.Text = dr[0].ToString ();
male.Text = dr[1].ToString ();
fmale.Text = dr [2].ToString ();
bsexes.Text = dr [3].ToString ();
landsize.Text = dr[4].ToString ();


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
My Dropdown List not inserting selected value into database. dababy ASP.NET 4 General Discussion 0 May 18th, 2012 08:14 AM
adding Dropdown list Items from SQLSERVER 2005 database biswa Pro VB Databases 1 October 23rd, 2009 10:46 AM
Data from Dropdown List to TextBox caterpillar General .NET 1 July 10th, 2006 06:05 AM
Retrieving the list of tables from a database devi.g@india.com J2EE 0 February 2nd, 2005 09:54 PM
Retrieving list of tables inside a database... vb_developer SQL Server ASP 6 September 13th, 2004 10:47 AM

All times are GMT -4. The time now is 01:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.