| | |
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 14 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; 14 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 algorithm array asp barchart bitmap box broadcast buttons c# check checkbox client column combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development display draganddrop drawing encryption enum equation event excel file form format formbox forms formupdate function gdi+ httpwebrequest image index input install java label linux list listbox mandelbrot math mouseclick mysql networking operator packaging parse path photoshop picturebox pixelinversion post powerpacks programming radians regex remote remoting reporting richtextbox robot server sleep socket sql statistics stream string table text textbox thread time timer transform treeview update usercontrol validation visualstudio webbrowser wfa windows winforms wpf xml





