473,382 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

populate dropdownlist in asp.net 2.0 using c#

hi all
i am using 2 dropdownlist in my form. i need states(in a country) in both dropdownlist. wats the best method of populating it.
should i make table for states or bind it in code behind using insert property. there are more way of doing it. if you know other ways, please help. i am not using ajex control.
please reply fast.
thnx.
Feb 4 '08 #1
2 7308
krille
26
If you take the info from a database you can fill an DataTable with the SqlDataAdapter and then use the DataSource property on your drop down list.

ddlStates.DataSource = dtTable;
ddlStates.Bind();

Make sure to fill it in a if(!IsPostBack) section so you dont fill it every time you do a postback this will make your page run slow...
Feb 4 '08 #2
If you take the info from a database you can fill an DataTable with the SqlDataAdapter and then use the DataSource property on your drop down list.

ddlStates.DataSource = dtTable;
ddlStates.Bind();

Make sure to fill it in a if(!IsPostBack) section so you dont fill it every time you do a postback this will make your page run slow...
Thanx for reply.
but what i wana to know is "wat's best method of populating dropdownlist?". right now i don't have data in database. data is fixed its 20. should i store it in database, then access it, or just bind it in html(inline code) ? please replay ASAP. wats best method of doing it?
Feb 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff Johnson | last post by:
I'm trying to populate a DropDownList with two columns of data I'm receiving from a stored procedure. All the examples I've found so far have mentioned modifying the SQL and are written in VB. ...
9
by: Viktor Popov | last post by:
Hi , I'm trying to populate DropDownList from data base but it doesn't work. Could someone help me! My code is: private void Page_Load(object sender, System.EventArgs e) { // Put user...
0
by: jobs at webdos | last post by:
I have a formview that will either edit or insert records into a database. when I call the page with a query string ?x= its goes to edit mode and loads data from a datasource in the form and load...
4
by: =?Utf-8?B?UGFkYW0=?= | last post by:
How to get different tooltip for each listitem in dropdownlist in ASP.NET with C#. I am binding dropdownlist using database. Ofcourse each item in dropdownlist will be different. kindly do help...
0
by: =?Utf-8?B?UGFkYW0=?= | last post by:
How to get different tooltip for each listitem in dropdownlist using C#. I am binding dropdownlist using database. Ofcourse each item in dropdownlist will be different. kindly do help me.
2
by: lintolawrance | last post by:
hai friends, i need some help from u.i am trying to work with Ajax.i done some codes for developing dropdownlist using ajax.but it doesn't work.please help me to develop it. ...
0
coolv
by: coolv | last post by:
Hello Everyone I want to Reload Second Dropdownlist from selected value of first Dropdownlist using Ajax in ASp.NET Also I want a to make validation using Ajax on page. Can anyone help me. ...
0
coolv
by: coolv | last post by:
Hello Everyone I want to Reload Second Dropdownlist from selected value of first Dropdownlist using Ajax in ASp.NET Also I want a to make validation using Ajax on page. Can anyone help me. ...
5
by: ssmeshack | last post by:
Hi All, Im using VWD 2008 (c#), I have a question here. Im having a dropdownlist like this: <asp:DropDownList ID="ddlIssue" runat="server" AutoPostBack="True" ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.