I've looked everywhere for this (for days!) and cant seem to find and answer. I'm trying to build an application (VB) to where a customer clicks on a outfit and the dropdownlist populates with different sizes for that particular outfit from the database. Some outfits only comes in one size or all sizes. In my database (SQL) table, I have the datafields Small, Medium, Large but the dropdownlist can only use one datafield at a time. How do you code the dropdownlist to use multiple datafields? Or is there another way to put the sizes in the database? PLEEEEEEEEEEEEEEEEEEEEEEEEEEEAAASE help me!
Are you sure it's not your sql query that's the problem? Sounds like you're binding WHERE size = @size rather than WHERE outfit = @outfit
I'm sure the query is wrong because I'm no expert at .NET. I've switched attributes all around the codes and still cant get it. This is an example of what I have: I have small, medium, large datafields and want them in the dropdownlist when a user click on that particular outfit. But only one of the fields show out on the webpage. Is there another way to input multiple data in one datafield in the database? Or what is the correct query command? I'm stumped.
Well this doesnt work: <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="SELECT [Small], [Medium], [Large], [Queen], FROM [OutfitDatabase] " > </asp:DropDownList> Code (markup): No suggestions from you brilliant programmers here? I've seen you guys answer much more complicated stuff than this.
You database doesn't allow it. You can't bind multiple fields to the data control. What you need is a separate table that has the ItemId and the size. Some thing like this: +----------+---------------+-----------------+ |SizeID | [B]ItemID[/B] | [B]Size [/B] | +----------+---------------+-----------------+ | 1 | 1 | Small | +----------+---------------+-----------------+ | 2 | 1 | Medium | +----------+---------------+-----------------+ | 3 | 1 | Large | +----------+---------------+-----------------+ | 4 | 1 | Queen | +----------+---------------+-----------------+ Code (markup): Then your need a query with a join. Something like select sizes.sizeID, sizes.size from sizes innerjoin items on items.ItemID = sizes.ItemID