I have an sql select script that will execute and shows that there is data being selected when it is run. The problem I am having is trying to get that data to show in my calendar control. I wanted to change the calender by what department the user was from that logged in. Right now there is nothing showing and it will not show any data unless I hard code a department in it.
I am working with c# asp.net.
here is what I am doing to try and get the data
private DataSet GetData()
{
var CurrUser = "a73 ";
var UsrDepartment = "60 ";
Account.Login uusr = new Account.Login();
CurrUser = uusr.User.Identity.Name.ToString().ToUpper();
ConnectionStringSettingsCollection cssc = ConfigurationManager.ConnectionStrings;
var sql = "select (substring(status, 1,1)) AS stat1, lastname, firstname, ldate, edate,depdivid, requestid from TIME.employee E inner join TIME.request T on E.EMPID = T.empid where E.depdivid = @UsrDepartment ";
using (iDB2Connection conn = new iDB2Connection(GetConnectionString()))
{
conn.Open();
using (iDB2Command cmd = new iDB2Command(sql, conn))
{
cmd.DeriveParameters();
using (iDB2DataAdapter da = new iDB2DataAdapter(cmd))
{
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}
}
}
I fill the calendar with this :
DataSet ds = GetData();
foreach (DataRow row in ds.Tables[0].Rows)
{
//need to fill from first to last date
string scheduledDate = Convert.ToDateTime(row["ldate"]).ToShortDateString();
string endDate = Convert.ToDateTime(row["edate"]).ToShortDateString();
e.Cell.Width = 120;
e.Cell.Height = 100;
Int32 start = 0;
Int32 end = 0;
start = string.CompareOrdinal(scheduledDate, s);
end = string.CompareOrdinal(endDate, s);
if ((start <= 0) & (end >= 0) & (!e.Day.IsWeekend))
{
HyperLink lb = new HyperLink();
lb.Text = link + (Int64)row["requestid"] + "' >" + row["lastname"] + "</a>" as String + "(" + row["stat1"] + ")" as String + "<br />";
//code to change color of button
if (scheduledDate == endDate)
{
lb.CssClass = "changecolor";
}
e.Cell.Controls.Add(lb);
}
}
This way will show no links in my calendar, but if I make the department have a value(which is not what I wanted) it will show the links.
I think you need a line like this