View Single Post
  #1 (permalink)  
Old May 21st, 2005, 05:21 PM
marty_nguyen marty_nguyen is offline
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


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>
                                            <asp:Label id="lblProdLine" runat="server" text='<%# Container.DataItem("Product Line") %>'></asp:Label>
                                            <asp:DropDownList id="DD_ProdLine_SS" runat="server" datavaluefield="Product Line" datatextfield="Product Line" datasource="<%#GetProdLine_SS()%>"></asp:DropDownList>
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


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
PL 1
PL 2
PL 3


Reply With Quote