在文本框TextChanged上过滤Rad网格

时间:2014-09-03 12:46:11

标签: c# asp.net

我试图在ASP.Net C#中的文本框文本更改的基础上过滤rad网格,就像当用户在文本框格中输入B时应该在列上过滤说出以B开头的员工姓名。我试过像跟随的东西。  我的C#代码

 protected void txtSearchName_TextChanged(object sender, EventArgs e)
        {
            DataTable dtUserDetails = new DataTable();           
                DataView dvStores = new DataView(dtEmployeeDetail);
                dvStores.RowFilter = "EmployeeName LIKE '" + txtSearchName.Text + "%'";
                rgEmployeeDetail.DataSource = dvStores;                                
        }

这里dtEmployeeDetail是包含EmployeeName列

的所有数据的表

我在asp页面中的文本框和网格如下

    <telerik:RadTextBox ID="txtSearchName" runat="server" DisplayText="Search" AutoPostBack="true" OnTextChanged="txtSearchName_TextChanged">
                                        </telerik:RadTextBox>
Grid

<telerik:RadGrid ID="rgEmployeeDetail" runat="server" AllowPaging="true" ShowGroupPanel="false"
                                    AutoGenerateColumns="false" PageSize="20" EnableAriaSupport="true" OnItemCommand="rgEmployeeDetail_ItemCommand"
                                    OnNeedDataSource="rgEmployeeDetail_NeedDataSource" OnInit="rgEmployeeDetail_Init">                                   
                                    <MasterTableView Width="100%" TableLayout="Fixed">
                                        <PagerStyle AlwaysVisible="true" ShowPagerText="False" PageSizeLabelText="" Mode="NextPrevAndNumeric" />
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" Visible="false">
                                                <HeaderStyle Width="25%" />
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="UserID" HeaderText="Global Id">
                                                <HeaderStyle Width="25%" />
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="EmployeeName" HeaderText="Employee Name">
                                                <HeaderStyle Width="50%" />
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Extension Number" HeaderText="Extension Number">
                                                <HeaderStyle Width="25%" />
                                            </telerik:GridBoundColumn>
                                        </Columns>

                                        <EditFormSettings>
                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                            </EditColumn>
                                        </EditFormSettings>
                                    </MasterTableView>
                                    <ClientSettings AllowKeyboardNavigation="true">
                                        <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" />
                                    </ClientSettings>
                                    <PagerStyle PageSizeLabelText="" ShowPagerText="False" />
                                    <FilterMenu EnableImageSprites="False">
                                    </FilterMenu>
                                </telerik:RadGrid>

但是根据新的Dataview,它的工作网格没有被过滤。

1 个答案:

答案 0 :(得分:0)

请检查......您是否在下面的行之后调用rgEmployeeDetail.DataBind() rgEmployeeDetail.DataSource = dvStores;

如果没有解决..请在rad网格上启用EnableqExpressions = false并检查