我正在尝试在下拉列表选择中为RadGrid设置过滤器中的值。
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("versionId");
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = VersionsCB.SelectedValue;
RadGrid1.Rebind();
这会填充versionId过滤器框中的版本,并将其设置为“EqualTo”,但不会过滤网格。我错过了什么?
编辑:aspx:
<telerik:RadGrid
ID="RadGrid1"
runat="server"
AllowFilteringByColumn="True"
AllowPaging="True"
AllowSorting="True"
AutoGenerateDeleteColumn="True"
AutoGenerateEditColumn="True"
DataSourceID="SqlDataSource1"
GridLines="None"
AllowAutomaticDeletes="True"
AllowAutomaticInserts="True"
AllowAutomaticUpdates="True"
PageSize="50"
Skin="Hay">
<ClientSettings>
<Scrolling AllowScroll="False" UseStaticHeaders="False" ScrollHeight="620"/>
</ClientSettings>
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="id" CommandItemDisplay="TopAndBottom">
<Columns>
<telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id" ReadOnly="True" SortExpression="id" UniqueName="id"></telerik:GridBoundColumn>
.
.
.
<telerik:GridBoundColumn DataField="versionId" DataType="System.Int32" HeaderText="versionId" ReadOnly="False" SortExpression="versionId" UniqueName="versionId"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
</telerik:RadGrid>
答案 0 :(得分:9)
试试这个:
RadGrid1.MasterTableView.FilterExpression = "([versionId] = "+VersionsCB.SelectedValue+")";
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("versionId");
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = VersionsCB.SelectedValue;
RadGrid1.Rebind();
在.aspx文件中修改RadGrid定义: