Atlas学习日记(一)
今天第一次用UpdatePanel,刚开始,不知道为什么不会实现局部刷新,看了好长时间,才知道,忘记设置EnablePartialRendering="True" ,这是<atlas:ScriptManager>的一个属性,但就是这个属性才能使UpdatePanel发挥强大的吸引力.
下面是我的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false" EnableScriptComponents="true" />
<div>
<atlas:UpdatePanel>
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="CstName" DataValueField="CstName" AutoPostBack="True">
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CPIC2_CSTConnectionString %>"
SelectCommand="SELECT [CstName] FROM [Customer]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" AllowSorting="True">
<PagerSettings Mode="NextPreviousFirstLast" />
<Columns>
<asp:BoundField DataField="CstName" HeaderText="CstName" SortExpression="CstName" />
<asp:BoundField DataField="Birth" HeaderText="Birth" SortExpression="Birth" />
<asp:BoundField DataField="IndentityType" HeaderText="IndentityType" SortExpression="IndentityType" />
<asp:BoundField DataField="Vocation" HeaderText="Vocation" SortExpression="Vocation" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<atlas:ControlValueTrigger ControlID="DropDownList1" PropertyName="SelectedValue" />
</Triggers>
</atlas:UpdatePanel>
</div>
</form>
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
</references>
<components>
</components>
</page>
</script>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CPIC2_CSTConnectionString %>"
SelectCommand="SELECT [CstName], [Birth], [IndentityType], [Vocation] FROM [Customer] where CstName=@CstName ">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CstName" Type="string" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</body>
</html>