Click here to Skip to main content
14,870,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a gridview and used one dropdown and a boundcolumn and bind gridview and dropdownlist by sqldatasource.
When I am excuting program then result display in simple column there are not showing dropdownlist I am unable to know.

Please suggest me

my code is...

<asp:GridView ID="grd1" runat="server" DataSourceID="SqlDataSource1"
            AutoGenerateColumns="False" DataKeyNames="Product_Id">
                <asp:TemplateField HeaderText="Product_Name" SortExpression="Product_Name">
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
                            DataTextField="Product_Name" DataValueField="Product_Id" SelectedValue='<%# Bind("Product_Name") %>'>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Product_Name") %>'></asp:Label>
                <asp:BoundField DataField="Product_Rate" SortExpression="Product_Rate" HeaderText="Product_Rate"/>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:chalk_hillConnectionString %>"
            SelectCommand="SELECT [Product_Id],[Product_Name], [Product_Rate]  FROM [Product_Detail]">
                <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:chalk_hillConnectionString %>"
            SelectCommand="SELECT DISTINCT [Product_Id],[Product_Name] FROM [Product_Detail]">
Updated 24-Oct-10 21:47pm
Dalek Dave 25-Oct-10 3:47am
Edited for Grammar and Readability.

1 solution

Your dropdown has datasource as SqlDataSource2. You use, 'Product_Name' & 'Product_Id' from it BUT I don't see 'Product_Id' selected in SqlDatasource2
call to .net 25-Oct-10 2:50am
I did with both product_id as well as with out product_id but record display inside gridview but these product_name showing simple column not in dropdowmn while i want product_name in dropdownlist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900