ASP.NET Podcast Show #52 - Its our Birthday and Wally talks about the Atlas Update Panel
http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2006/05/19/316.aspx
Subscribe – Really the only way to do things. Use Juice, iTunes, or something, but just SUBSCRIBE!
Download – Snore and boring (you really should subscribe)
- Its our first birthday.
- Craig Shoemaker.
- Simone Chiaretta.
- Wally and Paul chew the fat.
- Atlas Update Panel.
ASPX Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PartialUpdates.aspx.cs" Inherits="PartialUpdates_PartialUpdates" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Update Panel Page</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<div>
</div>
<div>
<table>
<tr>
<td><asp:Label runat="server" ID="lblEmployee">Employee:</asp:Label></td>
<td><asp:DropDownList runat="server" ID="ddlEmployee"></asp:DropDownList></td>
</tr>
<tr>
<td colspan="2">
<asp:Button runat="server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
</div>
<atlas:UpdatePanel runat="server" ID="upSearch" Mode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvSearchResults" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField AccessibleHeaderText="Last Name" DataField="LastName" HeaderText="Last Name" />
<asp:BoundField AccessibleHeaderText="First Name" DataField="FirstName" HeaderText="First Name" />
<asp:BoundField AccessibleHeaderText="Project Name" DataField="ProjectName" HeaderText="Project Name" />
<asp:BoundField AccessibleHeaderText="Date Work Performed" DataField="DateWorkPerformed"
DataFormatString="{0:MM-dd-yyyy}" HeaderText="Date Work Performed" HtmlEncode="false" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="btnSearch" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
</form>
</body>
</html>
Code Behind Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml;
public partial class PartialUpdates_PartialUpdates : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ListItem liItem;
if (Page.IsPostBack == false)
{
DataTable dtData = cCommon.GetEmployees();
this.ddlEmployee.Items.Add(String.Empty);
foreach (DataRow drData in dtData.Rows)
{
liItem = new ListItem(Convert.ToString(drData["LastName"]) + ", " +
Convert.ToString(drData["FirstName"]), Convert.ToString(drData["tblEmployeeId"]));
this.ddlEmployee.Items.Add(liItem);
}
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
string EmployeeId = this.ddlEmployee.SelectedItem.Value;
try
{
if (EmployeeId != String.Empty)
{
DataTable dtData = cCommon.GetData(Convert.ToInt32(EmployeeId));
this.gvSearchResults.DataSource = dtData;
this.gvSearchResults.DataBind();
}
}
finally
{
}
}
}