当我更改下拉列表的值时,GridView不会更改 这是我的代码:
的DropDownList:
<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>
GridView的:
<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();
}
答案 0 :(得分:1)
在调用DataBind方法之前,尝试再次设置GridView1.DataSource。
答案 1 :(得分:0)
我认为你不需要在回发期间在网格上调用DataBind()。尝试只使用空的下拉事件接收器。