当我更改下拉列表的值时,GridView 不会改变这是我的代码:
下拉列表:
<table>
<tr>
<td style="height: 49px"><asp:Label ID="Label1" runat="server" >Etablissement</asp:Label>
</td>
<td style="height: 49px">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="NOM_ETABL" DataValueField="CD_ETAB" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_TextChanged" />
</td>
<td>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionAREF %>" SelectCommand="getPrescolaireEtablissement" SelectCommandType="StoredProcedure" />
</td>
</tr>
</table>
网格视图:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
<div id="footer">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionAREF %>" SelectCommand="getPreInscriptionPublic" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CD_ETAB" PropertyName="SelectedValue" Type="String" />
<asp:Parameter Name="afficher" Type="Boolean" DefaultValue="true" />
</SelectParameters>
</asp:SqlDataSource>
</div>
代码隐藏:
protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
GridView1.DataBind();
}