{head}Code (C#){/head}
{cs}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace EHR
[
public partial class newaccord : System.Web.UI.Page
[
protected void Page_Load(object sender, EventArgs e)
[
LoadAccordion();
]
protected void LoadAccordion()
[
Accordion1.SelectedIndex = -1;
int cloop,maxyear, minyear;
System.Data.SqlClient.SqlConnection objConn;
System.Data.SqlClient.SqlCommand objCmd;
String strConnString, strSQL;
strConnString = "Serverxxx.xxx.x.xx;UID=sa;PASSWORD=*******;database=HR;Max Pool Size=400;Connect Timeout=600;";
objConn = new System.Data.SqlClient.SqlConnection(strConnString);
objConn.Open();
strSQL = "select convert(int,maxyear) as maxyear,convert(int,minyear) as minyear,convert(int,maxyear)-convert(int,minyear) as cloop from(select min(distinct substring(train_date,7,4)) as minyear,max(distinct substring(train_date,7,4)) as maxyear from dbo.hris_train_masterdata where pid=(select pid from dbo.hris_employee_data where code='165000020') ) as a";
System.Data.SqlClient.SqlDataReader dtReader;
objCmd = new System.Data.SqlClient.SqlCommand(strSQL, objConn);
dtReader = objCmd.ExecuteReader();
if (dtReader.HasRows)
[
if (dtReader.Read())
[
maxyear = (int)dtReader["maxyear"];
minyear = (int)dtReader["minyear"];
cloop = (int)dtReader["cloop"];
if (!Page.IsPostBack)
[
for (int i = 1; i <= cloop; i++)
[
AjaxControlToolkit.AccordionPane ap = new AjaxControlToolkit.AccordionPane();
ap.ID = "AP_" + i.ToString();
string hlabel = "Header #" + i.ToString();
ITemplate ITcontent = new GenericTemplateImplementation(
delegate(Control container)
[
AjaxControlToolkit.Accordion ac = new AjaxControlToolkit.Accordion();
ac.ID = "ACCC_" + i.ToString();
ac.HeaderCssClass = "accordionHeader";
ac.HeaderSelectedCssClass = "accordionHeaderSelected";
ac.ContentCssClass = "accordionContent";
ac.SelectedIndex = -1;