Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2005, 05:21 PM
Registered User
 
Join Date: Apr 2005
Location: London, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to marty_nguyen
Default problem with dropdown list in datagrid

Hi,

Can someone help me with this prob i'm having with a dropdown list in a datagrid please!!!

I have a datagrid with a template column listing the "product line" of the record:

<asp:TemplateColumn HeaderText="Prod Line">
                                        <HeaderStyle width="50px"></HeaderStyle>
                                        <ItemTemplate>
                                            <asp:Label id="lblProdLine" runat="server" text='<%# Container.DataItem("Product Line") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:DropDownList id="DD_ProdLine_SS" runat="server" datavaluefield="Product Line" datatextfield="Product Line" datasource="<%#GetProdLine_SS()%>"></asp:DropDownList>
                                        </EditItemTemplate>
                                    </asp:TemplateColumn>
The datasource of the dropdown list in edit mode comes from a function GetProdLine_SS returning a dataset:

Function GetProdLine_SS() As System.Data.DataSet

strSQL = "SELECT [Product Line] FROM [Product_Lines] WHERE [Product Line Group 2] = 'Single Sales'"

dbCommand.CommandText = strSQL
dbCommand.Connection = dbConnection

dataAdapter.SelectCommand = dbCommand

dataAdapter.Fill(dataSet)

Return dataSet

End Function

The problem is the dropdown list is showing values which are returned from the dataset (returned from the function) ASWELL as the product lines from the records in the datagrid.

e.g. The records in the datagrid are:
Product Product Line
A PL 1
B PL 2
C PL 2

and the product lines in the product_line table are:
PL 1
PL 2
PL 3

the dropdown list in the productline table are showing values:
PL 1
PL 2
PL 2
PL 1
PL 2
PL 3

I only want it to show values from the product_lines table
i.e:
PL 1
PL 2
PL 3


HELP PLEASE!!!

Martin
Reply With Quote
  #2 (permalink)  
Old May 22nd, 2005, 06:16 PM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Martin, I am very new to this forum, but my suggestions are:
  1) look at the database structures, the primary and foreign keys and their relationships (1-to-many, or many-to-many) of the two tables you are linking or using in your drop-down list. From what u listed, it seems that the Product has multiple single sales (Product Line);
   2) try using the word "DISTINCT" in the select statement to obtain a single occurance of the Product Line, create a new table, New_Product_Line_Tbl. Then Display in the drop-down List, the Product and the New_Product_Line_Tbl, using the LEFT JOIN;
   3) look at #1 and #2 outside of the drop-down-list, to see what is actually going on at this point.

Hope this helps, hard to say with out looking at the structure of your tables.

Good Luck


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
Dropdown list in a datagrid maddy137 ASP.NET 1.0 and 1.1 Professional 0 May 19th, 2006 02:05 PM
populating a dropdown list within a datagrid in C# akshay144 General .NET 0 May 12th, 2006 04:44 AM



All times are GMT -4. The time now is 05:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.