0
我有嵌套在GridView
中的DropDownList
。如何過濾DropDownList
數據源,僅顯示活動的db行(列爲活動的位類型)或當前選定的DropDownList
的值?GridView中的已過濾DropDownList
以下部分代碼不起作用。有什麼辦法如何綁定到curent的GridView行數據(通過標記)?
<asp:GridView ID="GridView" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="PlasticTypeId"
DataSourceID="dsPlasticTypes">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:CheckBoxField DataField="Active" HeaderText="Active" SortExpression="Active" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField HeaderText="<%$ Resources:Labels, PlasticFamily %>" SortExpression="PlasticFamily.Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("PlasticFamily.Name") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlFamilies" runat="server" DataSourceID="dsFamilies" DataValueField="PlasticFamilyId"
DataTextField="Name" SelectedValue='<%# Bind("PlasticFamilyId") %>'/>
<asp:EntityDataSource ID="dsFamilies" runat="server"
ConnectionString="name=PlasticsDbEntities" OrderBy="it.Name"
DefaultContainerName="PlasticsDbEntities" EnableFlattening="False"
EntitySetName="PlasticFamilies"
Where="it.Active==true || [email protected]">
<WhereParameters>
<asp:ControlParameter Name="control" ControlID="ddlFamilies" PropertyName="SelectedValue" Type="Int32" />
</WhereParameters>
</asp:EntityDataSource>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
你能發表更詳細的關於你的要求嗎? – 2013-04-24 13:50:23
我建議你另一個解決方案,基於'DataView'和'RowFilter'鏈接:http://msdn.microsoft.com/fr-fr/library/system.data.dataview.rowfilter(v=vs.80).aspx – 2013-04-24 11:34:25