【问题标题】:ASP.NET DropDownList used in AccessDataSource SelectCommand?AccessDataSource SelectCommand 中使用的 ASP.NET DropDownList?
【发布时间】:2014-08-12 14:13:15
【问题描述】:

尝试添加 SelectParameter 并选择下拉菜单。页面没有失败,但没有过滤掉类名 - 不接受参数 @ClassName 隶属关系参数工作正常,但 @ClassName 没有!

WHERE ClassName = @ClassName   

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="AccessDataSource1" BackColor="White" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" 
    GridLines="Vertical" AllowSorting="True">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
        <asp:CheckBox ID="RowLevelCheckBox" runat="server" />
    </ItemTemplate>
    </asp:TemplateField>
        <asp:BoundField DataField="UsersDataTbl.StudentID" HeaderText="FDID" SortExpression="StudentID" />
        <asp:BoundField DataField="UsersDataTbl.LastName" HeaderText="Last Name" SortExpression="LastName" />
        <asp:BoundField DataField="UsersDataTbl.FirstName" HeaderText="First Name" SortExpression="FirstName" />
        <asp:BoundField DataField="UsersDataTbl.UserName" HeaderText="User Name" SortExpression="UserName" />
        <asp:BoundField DataField="UsersDataTbl.Affiliation" HeaderText="Affiliation" SortExpression="Affiliation" />
        <asp:BoundField DataField="UsersDataTbl.UID" HeaderText="UID" SortExpression="UID" />
    </Columns>
    <FooterStyle BackColor="#CCCCCC" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="#6699CC" />
</asp:GridView>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
    SelectCommand="SELECT [UsersDataTbl.StudentID], [UsersDataTbl.UserName], 
    [UsersDataTbl.LastName], [UsersDataTbl.FirstName], [UsersDataTbl.Affiliation], [UsersDataTbl.UID] 
    FROM [UsersDataTbl] WHERE [UsersDataTbl.Active] = True AND (UsersDataTbl.Affiliation = @Affiliation) 
    AND ([UsersDataTbl.UID] NOT IN (SELECT UID FROM [EnrollmentsTbl] WHERE ClassName = @ClassName AND Completed = True))
    ORDER BY [UsersDataTbl.LastName]" >
    <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList2" Name="Affiliation" PropertyName="SelectedValue" Type="String" /> 
        <asp:ControlParameter ControlID="DropDownList1" Name="ClassName" PropertyName="SelectedValue" Type="String" />           
    </SelectParameters>
</asp:AccessDataSource>

【问题讨论】:

    标签: asp.net gridview drop-down-menu filter


    【解决方案1】:

    不知道为什么,但颠倒 ControlParameter 的顺序解决了问题,将 ClassName 移到 Affiliation 上方解决了问题...任何想法为什么?

    <asp:ControlParameter ControlID="DropDownList1" Name="ClassName" PropertyName="SelectedValue" Type="String" />
    <asp:ControlParameter ControlID="DropDownList2" Name="Affiliation" PropertyName="SelectedValue" Type="String" /> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多