我是ASP.NET新手,請原諒我,如果這是一個簡單的問題。頁面無法顯示在下拉列表中AutoPostBack
我正在一個頁面上有一個下拉菜單,在選擇一個選項後,它應該在下面的表格中顯示該數據。當選擇下拉菜單時,我無法顯示頁面。有任何想法嗎?
代碼:
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>
<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>
$
在你的代碼中是否有任何錯誤?它是否顯示與asp.net錯誤的黃頁? – Asdfg
你是否在調試模式下運行它,並得到任何錯誤? –
您正在使用控件'DropDownList2'指定一個參數,但您的源代碼中沒有'DropDownList2' –