Display data in drop down

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is offline Offline
Junior Poster

Display data in drop down

 
0
  #1
Feb 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Display data in drop down

 
0
  #2
Feb 15th, 2008
"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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is offline Offline
Junior Poster

Re: Display data in drop down

 
0
  #3
Feb 15th, 2008
Thanks for the response. My ddl looks like this:

  1.  
  2. <asp:DropDownList ID="DropDownListEquip" runat="server" CssClass="maintext"
  3. DataSourceID="Equipment" DataTextField="mfgID" DataValueField="mfgID">
  4. </asp:DropDownList>

Here is the datasource:

  1.  
  2. <asp:SqlDataSource
  3. ID="Equipment"
  4. runat="server"
  5. ConnectionString="<%$ ConnectionStrings:HRIServiceConnectionString1 %>"
  6. SelectCommand="SELECT a.Company, b.Description FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID">
  7. <SelectParameters>
  8. <asp:ControlParameter
  9. ControlID="DropDownList1"
  10. Name="cusID"
  11. PropertyName="SelectedValue"
  12. Type="String" />
  13. </SelectParameters>
  14. </asp:SqlDataSource>

And here is the error:

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'mfgID'.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Display data in drop down

 
0
  #4
Feb 15th, 2008
That says that there is no column in your table with the name of mfgID
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is offline Offline
Junior Poster

Re: Display data in drop down

 
0
  #5
Feb 15th, 2008
Au Contrair ... there is a mfgID in both Manuf and Equip. Which table is the error referring to?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Display data in drop down

 
0
  #6
Feb 15th, 2008
doesn't say. Could be either.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is offline Offline
Junior Poster

Re: Display data in drop down

 
0
  #7
Feb 15th, 2008
Ok, here is what I did. I removed ...
DataTextField="mfgID" DataValueField="mfgID"
from the ddl.

Now "System.Data.DataRowView" shows up in the ddl as the selection. It's not working but the error didn't come up this time.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Display data in drop down

 
0
  #8
Feb 15th, 2008
It's not working because you have no values to assign to it. And it won't fail cause nothing was done in the first place.

Check both your databases to assure yourself that mfgID is spelled correctly and exists in both tables.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is offline Offline
Junior Poster

Re: Display data in drop down

 
0
  #9
Feb 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Display data in drop down

 
0
  #10
Feb 15th, 2008
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:
  1. "SELECT Company, mfgID FROM Manufacturers"
Then, after the user picks the DDL, you want to populate a datalist or gridview or whatever with the correct info:
  1. "SELECT a.Company, b.Description FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID"
Am I right?
Last edited by SheSaidImaPregy; Feb 15th, 2008 at 3:48 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC