AJax技术

asp.net ajax技巧2

字号+ 作者:H5之家 来源:H5之家 2015-10-31 19:13 我要评论( )

下面是异步的一对多流程,有两个gridview,上面一个gridview是主,下面一个GRIDVIEW显示的是从,当点

下面是异步的一对多流程,有两个gridview,上面一个gridview是主,下面一个GRIDVIEW显示的是从,当点
主表的数据时,下面的GRIDVIEW显示对应的数据(DETAIL),要注意的是,为了防止浪费时间,把两个GRIDVIEW
放到两个不同的updatepannel中去,并且设计两个UPDATEPANNEL控件的updatemode属性为conditional,这样当在下方的GRIDVIEW控件排序时,上方的UPDATEPANNEL控件不会被局部更新
<asp:ScriptManager runat="server" />
<asp:UpdatePanel UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView AllowPaging="True" AllowSorting="True" Caption="订货主档的订单数据"
DataKeyNames="订单号码" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" SelectedIndex="0"
OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True"></asp:CommandField>
</Columns>
<FooterStyle BackColor="Tan" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
<asp:SqlDataSource runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,客户编号,员工编号,订单日期 FROM dbo.订货主档"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView runat="server" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px" Caption="订货明细资料" CellPadding="3" DataKeyNames="订单号码,产品编号"
DataSourceID="SqlDataSource2" GridLines="Horizontal" AllowSorting="True">
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
<EmptyDataTemplate>
<b><i>请您从以上的清单中选取一笔订单.....</i></b>
</EmptyDataTemplate>
<EmptyDataRowStyle BackColor="#404040" ForeColor="Red" />
</asp:GridView>
<br />
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,产品编号,单价,数量,折扣 FROM dbo.订货明细 WHERE (订单号码 = @OrderID)"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="PageIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="Sorted" />
</Triggers>
</asp:UpdatePanel>

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • JQuery实现Ajax加载图片的方法

    JQuery实现Ajax加载图片的方法

    2016-02-24 17:01

  • 判断用户是不是为ajax请求

    判断用户是不是为ajax请求

    2016-02-24 17:00

  • Ajax与WEB开发 by alixixi.com

    Ajax与WEB开发 by alixixi.com

    2016-02-11 11:02

  • jQuery.ajax()的相关参数及使用

    jQuery.ajax()的相关参数及使用

    2016-02-08 16:00

网友点评