| | |
Display data in drop down
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
I have a drop down that will be auto populated when the user selects a previous drop down. The one in question is referencing a particular piece of equipment attached to the company that was selected. The database is set up with a manufacturer table, equipment table, and customer equipment table. My issue is not knowing the correct SQL statement to write in order to display the appropriate equipment. The display in the drop should pull manufacturer name from the mfg table and the description from the equipment table at the same time it should be the unique equipment for that company (that is based on the serial number). A helping hand is much appreciated.
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
"SELECT a.manufacturername, b.description FROM manufacturer a JOIN equipment b ON a.manufacturerID=b.manufacturerID"
This assumes that you have a relational database and they are setup like this:
Manufacturer
- manufacturerID
- manufacturername
Equipment
- manufacturerID
- equipmentID (unique or Primary)
- description
This assumes that you have a relational database and they are setup like this:
Manufacturer
- manufacturerID
- manufacturername
Equipment
- manufacturerID
- equipmentID (unique or Primary)
- description
Thanks for the response. My ddl looks like this:
Here is the datasource:
And here is the error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'mfgID'.
ASP.NET Syntax (Toggle Plain Text)
<asp:DropDownList ID="DropDownListEquip" runat="server" CssClass="maintext" DataSourceID="Equipment" DataTextField="mfgID" DataValueField="mfgID"> </asp:DropDownList>
Here is the datasource:
ASP.NET Syntax (Toggle Plain Text)
<asp:SqlDataSource ID="Equipment" runat="server" ConnectionString="<%$ ConnectionStrings:HRIServiceConnectionString1 %>" SelectCommand="SELECT a.Company, b.Description FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="cusID" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
And here is the error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'mfgID'.
There's only on db and the tables in question definitely have mfgID and it is spelled correctly.
The difference I see between this ddl an the others I have on this page is DataTextField="mfgID". The others have something different than the datavaluefield. I'm just not sure what is supposed to be in this case.
The difference I see between this ddl an the others I have on this page is DataTextField="mfgID". The others have something different than the datavaluefield. I'm just not sure what is supposed to be in this case.
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
Oh woops, I wasn't paying attention.
You can only put values you retrieve into the DROPDOWNLIST. You never pulled mfgID so you cannot use it as a TextValue or DataValue. That query you want this:
Then, after the user picks the DDL, you want to populate a datalist or gridview or whatever with the correct info:
Am I right?
You can only put values you retrieve into the DROPDOWNLIST. You never pulled mfgID so you cannot use it as a TextValue or DataValue. That query you want this:
ASP.NET Syntax (Toggle Plain Text)
"SELECT Company, mfgID FROM Manufacturers"
ASP.NET Syntax (Toggle Plain Text)
"SELECT a.Company, b.Description FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID"
Last edited by SheSaidImaPregy; Feb 15th, 2008 at 3:48 pm.
![]() |
Similar Threads
- Winsock Multi-Client Servers (C++)
- Make data from a pull down list mandatory (Visual Basic 4 / 5 / 6)
- Retrieve data from a table in mysql and edit the contents (PHP)
- Please help me :"login form use drag and drop toolbox" ! (C#)
- PHP mysql drop down populates another drop down (PHP)
- Reading from a text file and using it as a database (Visual Basic 4 / 5 / 6)
- help with treeview property setting (Python)
- Filtering My sql through Php using drop down menu and text field (PHP)
- Display Search Results as Hyperlinks to Records (ASP)
- JSP and Oracle (JSP)
Other Threads in the ASP.NET Forum
- Previous Thread: asp.net
- Next Thread: LiveCD and ASP.NET
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers






