Click here to Skip to main content
14,423,094 members
Rate this:
Please Sign up or sign in to vote.
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 22:47pm
Dalek Dave 25-Oct-10 3:47am
Edited for Grammar and Readability.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100