My scenario is to build an Employee Infomation Management Module.
First of all, I invoke a method contained in some DataAccess Class to get all the departments of the company, and then add a Pane for each of department. (I do this via the DataSource property)
I handle the ItemDataBound event of the Accordion control to get employees' information (via Data Access Class, too) of each department and bind it to a DataList contained in the Pane.
In the DataList item template, I add a LinkButton to each item in order to trigger a edit operation (show employee's information in a ModalPopupExtender-linked Panel).
All things are just great untill I clicked the Edit LinkButton in the DataList. NOTHING happened. It seems that the Click event of the LinkButton is not fired at all.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserAccountManage.aspx.cs"
Inherits="admin_RoleAuthority_UserAccountManage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %>
<!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>Employee Management</title><link href="../../App_Themes/styles.css" rel="stylesheet" type="text/css" />
<style>
.AtonAccordion
{
border: 1px solid #ccc;
}
.AtonHeader
{
border: 1px solid #2F4F4F;
color: white;
background-color: #2E4d7B;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}
.AtonContent
{
background-color: #D3DEEF;
border: 1px dashed #2F4F4F;
border-top: none;
padding: 5px;
padding-top: 10px;
}
.style1
{
width: 64px;
}
.style2
{
width: 135px;
}
</style>
</head>
<body style="margin-left: 10px; margin-top: 10px">
<form id="form1" runat="server">
<div class="txt">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="plUserAccount" OkControlID="Button1"
CancelControlID="Button2" TargetControlID="plUserAccount">
</cc1:ModalPopupExtender>
<font size="4"><b>Employee Management</b></font><br />
<cc1:Accordion ID="Accordion1" runat="server" CssClass="AtonAccordion" HeaderCssClass="AtonHeader"
ContentCssClass="AtonContent" OnItemDataBound="Accordion1_ItemDataBound" FadeTransitions="true"
FramesPerSecond="20" Width="300px" SuppressHeaderPostbacks="true">
<HeaderTemplate>
<asp:Label ID="lblDepartmentName" runat="server" Text='<%# Eval("DepartmentName") %>'></asp:Label>
</HeaderTemplate>
<ContentTemplate>
<asp:DataList ID="dlEmployees" runat="server" CellSpacing="3" DataKeyField="ID">
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Employee Name" Width="75px" ForeColor="blue" Font-Bold="true"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Login Name" Width="100px" ForeColor="blue" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblEmployeeName" runat="server" Text='<%# Eval("EmployeeName") %>'
Width="75px"></asp:Label>
<asp:Label ID="lblLoginName" runat="server" Text='<%# Eval("LoginName") %>' Width="100px"></asp:Label>
<asp:LinkButton ID="lnkbtnEdit" runat="server" ToolTip='<%# Eval("ID") %>' CommandName="edit" OnClick= "lnkbtnEdit_Click">Edit</asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</cc1:Accordion>
<asp:Panel runat="server" ID="plUserAccount" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="1px" Width="300px">
<center>
<b><br />Employee Information</b>
</center>
<br />
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td class="style1">Employee Name</td><td class="style2">
<asp:Label ID="lblEmployeeName" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td class="style1">Login Name</td><td class="style2">
<asp:TextBox ID="txtLoginName" runat="server" Width="100px"></asp:TextBox>
</td>
</tr>
</table>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" style="display:none" /><asp:Button ID="Button2"
runat="server" Text="Button" style="display:none" />
<center>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" Width="71px" />
<asp:Button ID="btnCancel" runat="server" Text="Close" OnClick="btnCancel_Click" Width="70px" />
<br />
<br />
</center>
</asp:Panel>
</div>
</form>
</body>
</html>