带有gridview的下拉列表 [英] DropDown list with gridview
本文介绍了带有gridview的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个gridview并使用了一个下拉列表和一个绑定列,并通过sqldatasource绑定了gridview和dropdownlist.
当我执行程序时,结果显示在简单列中,没有显示我不知道的下拉列表.
请建议我
我的代码是...
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">
<Columns>
<asp:TemplateField HeaderText="Product_Name" SortExpression="Product_Name">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="Product_Name" DataValueField="Product_Id" SelectedValue='<%# Bind("Product_Name") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Product_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Product_Rate" SortExpression="Product_Rate" HeaderText="Product_Rate"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:chalk_hillConnectionString %>"
SelectCommand="SELECT [Product_Id],[Product_Name], [Product_Rate] FROM [Product_Detail]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:chalk_hillConnectionString %>"
SelectCommand="SELECT DISTINCT [Product_Id],[Product_Name] FROM [Product_Detail]">
</asp:SqlDataSource>
推荐答案
ConnectionStrings:chalk_hillConnectionString %> " span> =" 从[Product_Detail]中选择[Product_Id],[Product_Name],[Product_Rate]" < /asp:SqlDataSource > < asp:SqlDataSource ID =" runat 服务器" span> =" <%
ConnectionStrings:chalk_hillConnectionString %>" SelectCommand="SELECT [Product_Id],[Product_Name], [Product_Rate] FROM [Product_Detail]"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%
ConnectionStrings:chalk_hillConnectionString span> =" 从[Product_Detail]中选择DISTINCT [Product_Id],[Product_Name]" < /asp:SqlDataSource >
ConnectionStrings:chalk_hillConnectionString %>" SelectCommand="SELECT DISTINCT [Product_Id],[Product_Name] FROM [Product_Detail]"> </asp:SqlDataSource>
您的下拉列表中的数据源为SqlDataSource2.您使用的是"Product_Name"和"Product_Id",但我看不到SqlDatasource2中选择的"Product_Id"
Your dropdown has datasource as SqlDataSource2. You use, ''Product_Name'' & ''Product_Id'' from it BUT I don''t see ''Product_Id'' selected in SqlDatasource2
这篇关于带有gridview的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文