DropDown Picking values from database

Posted by Nishadullas under ASP.NET on 9/24/2011 | Points: 10 | Views : 1756 | Status : [Member] | Replies : 6
Hi...
I am facing a problem in ASP.net... i have created a web page and on that page there are almost 57 dropdowns and every dropdown picks values from database.
To solve this i have used SQlDataSource control of asp.net for every dropdown. I don't know whether i am using the proper and correct way,But anyhow its really taking a big span of 7-8 seconds for loading the page.
Can anyone Help me to sort out my problem.

Thank you

regards
Nishad




Responses

Posted by: Blessyjees on: 9/26/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can try this with dataset.
SqlConnection sqlConnection = new SqlConnection("server=(local);database=[dbname];user id=username;password=password;connection reset=false;connection lifetime=5;min pool size=1;max pool size=50;");

sqlConnection.Open();
DataSet ds = new DataSet();
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("Select * FROM Table1 ", sqlConnection );
sqlDataAdapter .Fill(ds);
ddList.DataSource = ds;
ddList.DataTextField = "Table1Field";
ddList.DataValueField = "Table1Field";
ddList.DataBind();


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CS1401 on: 9/27/2011 [Member] Starter | Points: 25

Up
0
Down
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(dr["name"].ToString()));

this is best one.

...

Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishadullas on: 9/28/2011 [Member] Starter | Points: 25

Up
0
Down
Hi....Blesssyyy
Thank You for Blessing me....
Can you please tell me where should i write this code, On the pageload event or should create a class file..? I am a bit confused.
So please if possible guide me stepwise.

Thank You

regards
Nishad



Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishadullas on: 9/28/2011 [Member] Starter | Points: 25

Up
0
Down
Hi... CS1401....
Thank You for replying

Just one doubt ...whats that dr stands for? is that an object of DataReader?


Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CS1401 on: 9/29/2011 [Member] Starter | Points: 25

Up
0
Down
yes this is the datareader object.

...

Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CS1401 on: 9/29/2011 [Member] Starter | Points: 25

Up
0
Down
this is the only one line code instead of writing 6 to 8 lines. and efficient..

...

Nishadullas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response