Dropdown AutoPostBack无法显示页面

时间:2011-07-27 12:54:55

标签: c# asp.net visual-studio-2010

我是ASP.NET的新手,所以请原谅我这是一个简单的问题。

我正在处理一个包含下拉列表的页面,在选择了一个选项后,它应该在下表中显示该数据。选择下拉列表后,我无法显示页面。有什么想法吗?


代码:

                    Select an Account Number:

    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
        AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="AccountNumber" 
        DataValueField="AccountNumber">
        <asp:ListItem Value="" Text="Select an Account" /><asp:ListItem></asp:ListItem> 
    </asp:DropDownList>
    &nbsp;<br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource2" CellPadding="4" ForeColor="#333333" 
        GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:BoundField DataField="BusinessDistrict" HeaderText="BusinessDistrict" 
                SortExpression="BusinessDistrict" />
            <asp:BoundField DataField="SurveyDate" HeaderText="SurveyDate" 
                SortExpression="SurveyDate" />
            <asp:BoundField DataField="SurveyType" HeaderText="SurveyType" 
                SortExpression="SurveyType" />
            <asp:BoundField DataField="Division" HeaderText="Division" 
                SortExpression="Division" />
            <asp:BoundField DataField="AccountNumber" HeaderText="AccountNumber" 
                SortExpression="AccountNumber" />
            <asp:BoundField DataField="TownCode" HeaderText="TownCode" 
                SortExpression="TownCode" />
            <asp:BoundField DataField="Municipality" HeaderText="Municipality" 
                SortExpression="Municipality" />
            <asp:BoundField DataField="MeterLocation" HeaderText="MeterLocation" 
                SortExpression="MeterLocation" />
            <asp:BoundField DataField="CustomerName" HeaderText="CustomerName" 
                SortExpression="CustomerName" />
            <asp:BoundField DataField="MeterNumber" HeaderText="MeterNumber" 
                SortExpression="MeterNumber" />
            <asp:BoundField DataField="StreetAddr" HeaderText="StreetAddr" 
                SortExpression="StreetAddr" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:InitialREValveTrackConnectionString %>" 
        SelectCommand="SELECT [BusinessDistrict], [SurveyDate], [SurveyType], 
        [Division], [AccountNumber], [TownCode], [Municipality], [MeterLocation],  
        [CustomerName], [MeterNumber], [StreetAddr] FROM [tbl_Initial] WHERE 
        (([AccountNumber] = @AccountNumber) AND ([MeterNumber] = @MeterNumber))">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" DefaultValue="NULL" 
                Name="AccountNumber" PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownList2" DefaultValue="NULL" 
                Name="MeterNumber" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
$

1 个答案:

答案 0 :(得分:0)

<asp:ControlParameter ControlID="DropDownList2" DefaultValue="NULL" 
            Name="MeterNumber" PropertyName="SelectedValue" Type="String" />

你删除了这个并重试了吗?如果没有找到数据,我不确定它是否会忽略此参数。