【问题标题】:GridView disappears when using Control Parameters for filtering使用控制参数进行过滤时,GridView 消失
【发布时间】:2019-07-06 21:07:33
【问题描述】:

我有一个名为 gvPerson 的 GridView。我还创建了一个 TextBox 和 Button 用于通过 GridView 进行搜索。用户可以使用他们正在寻找的人员的 ID、姓名、职位和 PD 编号来搜索人员。我已通过 SQLDataSource 任务向导添加 ControlParameters。每次运行应用程序时,我都可以看到搜索文本框,但没有出现 GridView。只有当我在搜索框中输入名称时它才会出现。此外,当我为其他搜索要求(例如 ID、位置和 PD 编号)添加更多控制参数时,搜索功能不再起作用这是我目前所拥有的:


                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityDBConnectionString2 %>" SelectCommand="SELECT * FROM [Personnel] WHERE (([Status] = @Status) AND ([EmpName] LIKE '%' + @EmpName + '%'))">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="1" Name="Status" Type="Int32" />
                        <asp:ControlParameter ControlID="txtSearch" Name="EmpName" PropertyName="Text" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>

【问题讨论】:

    标签: sql asp.net vb.net gridview


    【解决方案1】:

    我通过使用 FilterParameters 并将 ControlParameters 添加到我的 SqlDataSource 使代码工作。我没有使用向导添加这两个,因为 GridView 会消失。

    【讨论】:

      猜你喜欢
      • 2013-08-16
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 2016-10-03
      • 1970-01-01
      • 2019-01-09
      相关资源
      最近更新 更多