| | |
get data from database in dropdown list
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
C# Syntax (Toggle Plain Text)
<asp:SqlDataSource ID="sda_nw1" runat="server" ConnectionString='<%$ ConnectionStrings:NORTHWIND %> ' SelectCommand="SELECT orders.customerid, ContactName, count(OrderID) as numorders FROM orders join customers on orders.CustomerID=Customers.CustomerID group by orders.customerid, ContactName order by ContactName" ProviderName="System.Data.SqlClient" OldValuesParameterFormatString="original_{0}"> </asp:SqlDataSource> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sda_nw1" DataTextField="customerid" DataValueField="customerid"> </asp:DropDownList><br />
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
•
•
Join Date: Oct 2009
Posts: 28
Reputation:
Solved Threads: 2
0
#6 16 Days Ago
You can add data that is returned from a reader the same way you would programmatically add items to a combobox (combobox1.Items.Add(*Object to add to combobox*);
Here is a sample of code that I did a while ago, this reads all of the Columns on a particular table and adds it to a combobox.
Here is a sample of code that I did a while ago, this reads all of the Columns on a particular table and adds it to a combobox.
C# Syntax (Toggle Plain Text)
for (int i = 0; i < dr.FieldCount; i++) { Fields.Add(dr.GetName(i)); comboBox1.Items.Add(dr.GetName(i)); }
Last edited by sanch01r; 16 Days Ago at 4:48 pm.
![]() |
Similar Threads
- Dropdown list in ASP.NET - How to get value selected (ASP.NET)
- dropdown list (VB.NET)
- Dynamic dropdown list (ASP.NET)
- Dropdown list Last value (ASP.NET)
- Retrieving Multiple Columns into Dropdown List (ASP.NET)
- DropDown List (VB.NET)
- Feeding a value in a dropdown list to another dropdown list (PHP)
Other Threads in the C# Forum
- Previous Thread: Active Directory Query and TreeView Help
- Next Thread: Reading txt file, casting to array, Display in listBox
| Thread Tools | Search this Thread |
.net access ado.net algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum equation event excel file form format formatting forms function gdi+ httpwebrequest image index input install interface java label list listbox mandelbrot math mouse mouseclick mysql namevaluepairs operator path photoshop picturebox pixelinversion post powerpacks programming property radians regex remote remoting resource restore richtextbox server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation visualstudio wait webbrowser windows winforms working wpf xml





