日期:2014-05-18  浏览次数:20486 次

无刷新页面更新数据控件的问题
本人对Ajax相对不会很熟悉,我要做一个页面,其中页面有两个控件
dropdownlist1     和     dropdownlist2  
dropdownlist1中的数据来源于代码绑定到数据库中的某一列,dropdownlist2的   数据来源要来自于dropdownlist1的选择值,然后再依据此值绑定出符合条件的数据列,我发现单纯用代码写,页面刷新过于厉害,各位有经验的高手能介绍如何用ASP.NET   Ajax   的相关控件进行解决吗?比如   ScriptManager控件

UpdatePanel控件  
还有更好、更通用的吗?
顺便能介绍怎么用上面说的这些控件?

------解决方案--------------------
给你个我自己写的 ,炫耀一下,用好了可要回来表扬我呀~~
<div>
<asp:ScriptManager ID= "ScriptManager1 " runat= "server ">
</asp:ScriptManager>
<asp:UpdatePanel ID= "UpdatePanel1 " runat= "server ">
<ContentTemplate>
<asp:DropDownList ID= "DropDownList1 " runat= "server " DataSourceID= "SqlDataSource1 "
DataTextField= "privince " DataValueField= "id " Width= "142px " AutoPostBack= "true "
AppendDataBoundItems= "true ">
<asp:ListItem Text= "请选择省份 " Value= "-1 "> </asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID= "SqlDataSource1 " runat= "server " ConnectionString= " <%$ ConnectionStrings:practise_adConnectionString %> "
SelectCommand= "SELECT * FROM [user_privince] "> </asp:SqlDataSource>
<br />

<asp:DropDownList ID= "DropDownList2 " runat= "server " DataSourceID= "SqlDataSource2 "
DataTextField= "city " DataValueField= "id " Width= "142px ">
</asp:DropDownList>
<asp:SqlDataSource ID= "SqlDataSource2 " runat= "server " ConnectionString= " <%$ ConnectionStrings:practise_adConnectionString2 %> "
SelectCommand= "select city,id from user_city where pid=@pid ">
<SelectParameters>
<asp:ControlParameter Name= "pid " ControlID= "DropDownList1 " PropertyName= "SelectedValue " />
</SelectParameters>
</asp:SqlDataSource>
&nbsp;
</ContentTemplate>

<Triggers>
<asp:AsyncPostBackTrigger ControlID= "DropDownList1 " EventName= "SelectedIndexChanged " />
<asp:AsyncPostBackTrigger ControlID= "Button1 " EventName= "Click " />
</Triggers>
</asp:UpdatePanel>
</div>
------解决方案--------------------
在网上搜一下小山博客