asp.net ajax技巧2
来源:互联网 发布:ecs windows 编辑:程序博客网 时间:2024/05/01 16:28
下面是异步的一对多流程,有两个gridview,上面一个gridview是主,下面一个GRIDVIEW显示的是从,当点
主表的数据时,下面的GRIDVIEW显示对应的数据(DETAIL),要注意的是,为了防止浪费时间,把两个GRIDVIEW
放到两个不同的updatepannel中去,并且设计两个UPDATEPANNEL控件的updatemode属性为conditional,这样当在下方的GRIDVIEW控件排序时,上方的UPDATEPANNEL控件不会被局部更新
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="OrdersPanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" AllowPaging="True" AllowSorting="True" Caption="订货主档的订单数据"
DataKeyNames="订单号码" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
runat="server" Width="608px" 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 ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,客户编号,员工编号,订单日期 FROM dbo.订货主档"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="OrderDetailsPanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px" Caption="订货明细资料" CellPadding="3" DataKeyNames="订单号码,产品编号"
DataSourceID="SqlDataSource2" GridLines="Horizontal" Width="608px" 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 ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,产品编号,单价,数量,折扣 FROM dbo.订货明细 WHERE (订单号码 = @OrderID)"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="OrderID" 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>
主表的数据时,下面的GRIDVIEW显示对应的数据(DETAIL),要注意的是,为了防止浪费时间,把两个GRIDVIEW
放到两个不同的updatepannel中去,并且设计两个UPDATEPANNEL控件的updatemode属性为conditional,这样当在下方的GRIDVIEW控件排序时,上方的UPDATEPANNEL控件不会被局部更新
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="OrdersPanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" AllowPaging="True" AllowSorting="True" Caption="订货主档的订单数据"
DataKeyNames="订单号码" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
runat="server" Width="608px" 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 ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,客户编号,员工编号,订单日期 FROM dbo.订货主档"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="OrderDetailsPanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px" Caption="订货明细资料" CellPadding="3" DataKeyNames="订单号码,产品编号"
DataSourceID="SqlDataSource2" GridLines="Horizontal" Width="608px" 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 ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT 订单号码,产品编号,单价,数量,折扣 FROM dbo.订货明细 WHERE (订单号码 = @OrderID)"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="OrderID" 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>
- asp.net ajax技巧2
- asp.net ajax技巧2
- asp.net ajax技巧7
- asp.net ajax技巧6
- asp.net ajax 技巧5
- asp.net ajax 技巧4
- asp.net ajax 技巧4
- asp.net ajax 技巧5
- asp.net ajax技巧6
- asp.net ajax技巧7
- asp.net ajax框架使用技巧之一
- asp.net 2.0 ajax技巧学习1
- asp.net 2.0 ajax技巧学习1
- Asp.Net Ajax (2)---ScriptManager
- asp.net ajax UpdatePanel使用技巧以及常见问题
- ExtAspNet应用技巧(三) - 302与Asp.Net Ajax
- ExtAspNet应用技巧(三) - 302与Asp.Net Ajax
- asp.net 2.0 技巧2
- (转)【Hibernate总结系列】使用举例
- (转)关于MYSQL数据的导出导入与版本的转换
- 装饰模式学习
- (转)Apache服务器使用.htaccess实现图片防盗链方法教程
- php里的include和require
- asp.net ajax技巧2
- asp.net 2.0 ajax技巧学习1
- asp.net 2.0技巧3
- (转)SQL Server高可用性部署实施
- asp.net 2.0 技巧2
- asp.net 2.0常见问题技巧1
- asp.net 2.0中显示主从关系另一个方法
- TOMCAT 5的一些优化笔记
- (转)遭遇PHP has encountered an Access Violation