Gridview列和下拉列表 [英] Gridview column and dropdown lists
问题描述
这让我发疯,对于似乎如此简单的事情,必须有一个很好的例子.
我有一个表,其中包含列名称和过滤器值,可供每个列选择.
我想在我的页面上显示一个gridview,其中第一列是列名称",第二列具有具有关联列名称的值的下拉列表.
样本数据:
表1
第1列第2列
颜色红色
颜色蓝色
颜色绿色
华盛顿西雅图
西澳塔科马
WA Burien
等...
gridview应该看起来像
第1列标题下拉列表值
颜色值的颜色下拉列表
WA WA值的下拉列表
该表是我需要绑定到gridview的SQL表.
到目前为止,我的aspx页面中确实有这个
This is driving me crazy and there must be a great example for something that seems so simple.
I have a table with column names and filter values to choose from for each column.
I want to display a gridview on my page where the 1st column is ''Column Name'' and the 2nd column has the dropdown of the values that have the associated column name.
Sample data:
Table1
Column 1 Column 2
Color Red
Color Blue
Color Green
WA Seattle
WA Tacoma
WA Burien
etc...
The gridview should look like
Column 1 header Dropdown values
Color Dropdown list of color values
WA Dropdown list of WA values
The table is a SQL table that I need to bind to the gridview.
I do have this so far in my aspx page
<asp:GridView ID="gvFilterOptions" runat="server" DataSourceID="SqlDS_UI_FilverValues"
GridLines="None" AutoGenerateColumns="False"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" HorizontalAlign="Center">
<PagerStyle CssClass="pgr"></PagerStyle>
<HeaderStyle BackColor="#000000" Font-size="12" ForeColor="White"/>
<Columns>
<asp:BoundField DataField="ColumnName" ItemStyle-Width="40%" HeaderText="Column" />
<asp:TemplateField HeaderText = "Values">
<ItemTemplate>
<asp:DropDownList ID="ddl_FilterList1" Width="250" runat="server"
SelectionMode="Multiple"
DataTextField="FilterValue" DataValueField="FilterValue">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
推荐答案
以下几篇文章可能对您有所帮助-
http://csharpdotnetfreak.blogspot.com/2009/02/ajax-cascading-dropdownlist- database.html [ ^ ]
http://www.dotnetcurry.com/ShowArticle.aspx?ID=221 [ ^ ]
Here are a couple of articles that might help you out -
http://csharpdotnetfreak.blogspot.com/2009/02/ajax-cascading-dropdownlist-database.html[^]
http://www.dotnetcurry.com/ShowArticle.aspx?ID=221[^]
谢谢.我将浏览这些
这篇关于Gridview列和下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!