我有ASP網頁連接GridView1
連接到SqlDataSource1
和DropDownList1
這對SqlDataSource1
SQL腳本產生影響。在GridView上刷新數據DropDownList選擇索引變化
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="terminalLog.aspx.cs" Inherits="_2013web.terminalLog" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Id" DataValueField="Id" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True" Height="95px" OnLoad="DropDownList1_Load" OnTextChanged="DropDownList1_TextChanged" Width="481px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:logsConnectionString1 %>" SelectCommand="SELECT [ClientID], [Msg], [LogLevel], [Date] FROM [logs] WHERE ([ClientID] = @ClientID) ORDER BY [Date]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="80" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="2104px">
<Columns>
<asp:BoundField DataField="ClientID" HeaderText="ClientID" SortExpression="ClientID" />
<asp:BoundField DataField="Msg" HeaderText="Msg" SortExpression="Msg" />
<asp:BoundField DataField="LogLevel" HeaderText="LogLevel" SortExpression="LogLevel" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:logsConnectionString1 %>" SelectCommand="SELECT [Id] FROM [clients] ORDER BY [Id]"></asp:SqlDataSource>
</asp:Content>
我需要在選擇DropDownList1
新的價值,以顯示新的數據。
我想我需要的東西,在那裏寫:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataSource1.Update();
}
SqlDataSource1.Update();
沒有幫助。
DropDownList1_SelectedIndexChanged
應該執行什麼?
GridView1.DataBind()如果你想刷新網格。 – 2015-03-03 12:06:11
'DropDownList1'連線到'SqlDatasource1'的控制參數和GridView屬性:'
fnostro
2015-03-03 21:58:16