Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Dropdownlist to pick up from ConfigurationManager

Author  Topic 

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-01-20 : 02:46:57
Hi all,

I am lost on how to populate it onto a dropdownlist from a web config id called "debugEmail".
Wanted to change the system such that when it is in the debugMode, user apply leave it will nt send email to inform the default approval set in the database but it will send to the debugEmail instead which is a key in web config and not found in database at all. Else, it will get the default approval from database.

public void PopulateApproval1DLL()
{

String isDebug = ConfigurationManager.AppSettings.Get("debugMode");
String sApprover;

if (isDebug == "true")
{
sApprover = ConfigurationManager.AppSettings.Get("debugEmail").ToString();
Session["sApprover1"] = sApprover;
ddlApproval1.SelectedValue = Session["sApprover1"].ToString();
ddlApproval1.Items.Insert(0, new ListItem(sApprover, sApprover));
}
else
{

dsApproval1Ht = lcr.GetApprovalListForDLL(leaveItem.Employee, 1);

int rows = dsApproval1Ht.Tables["Approval"].Rows.Count;

dtCol = new DataColumn();
dtCol.ColumnName = "EmployeeName";
dtApproval1.Columns.Add(dtCol);

dtCol = new DataColumn();
dtCol.ColumnName = "EmployeeID";
dtApproval1.Columns.Add(dtCol);



for (int i = 0; i < rows; i++)
{
dtRow = dtApproval1.NewRow();
dtRow["employeename"] = dsApproval1Ht.Tables["Approval"].Rows[i]["EmployeeName"].ToString();
dtRow["EmployeeID"] = dsApproval1Ht.Tables["Approval"].Rows[i]["EmployeeID"].ToString();
dtApproval1.Rows.Add(dtRow);
}

if (dsApproval1Ht.Tables["Approval"].Rows.Count == 0)
{

//Add the NA item
dtRow = dtApproval1.NewRow();
dtRow["EmployeeName"] = "NA";
dtRow["EmployeeID"] = "NA";
dtApproval1.Rows.Add(dtRow);
}

ddlApproval1.DataSource = dtApproval1;
ddlApproval1.DataTextField = "EmployeeName";
ddlApproval1.DataValueField = "EmployeeID";
ddlApproval1.DataBind();
}


//This Section is used because I wanted to add a NA selection




}
public void PopulateApproval2DLL()
{

String isDebug = ConfigurationManager.AppSettings.Get("debugMode");
String sApprover;
if (isDebug == "true")
{

sApprover = ConfigurationManager.AppSettings.Get("debugEmail").ToString();
Session["sApprover1"] = sApprover;
ddlApproval2.SelectedValue = Session["sApprover1"].ToString();
ddlApproval2.Items.Insert(0, new ListItem(sApprover, sApprover));
}
else
{

dsApproval2Ht = lcr.GetApprovalListForDLL(leaveItem.Employee, 2);
dvApproval2 = dsApproval2Ht.Tables["Approval"].DefaultView;
ddlApproval2.DataSource = dvApproval2;
ddlApproval2.DataTextField = "EmployeeName";
ddlApproval2.DataValueField = "EmployeeID";
ddlApproval2.DataBind();
}
}
   

- Advertisement -