I am getting the error The 'IListSource does not contain any data
sources' on the DataBind line in my code below. I have stepped through
and there are records in the data reader...in fact this code has been
working for over a year and has just now starting to give this error.
Can anybody help?
private void BindData()
{
string strLeadAssignme ntCount = "";
SqlConnection objConnection = new
SqlConnection(C onfigurationSet tings.AppSettin gs["constr"]);
objConnection.O pen();
//get row count
switch (intJobRoleKey)
{
//admin
case 2:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0";
break;
//CI
case 5:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 1";
break;
//DC
case 6:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 2";
break;
//Brokers
case 7:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 3";
break;
default:
Response.Redire ct("default.asp x");
break;
}
SqlCommand objCommandCount = new
SqlCommand(strL eadAssignmentCo unt, objConnection);
int intTotalRows =
Convert.ToInt32 (objCommandCoun t.ExecuteScalar ());
if (intTotalRows 0)
{
//now populate datareader with actual data
SqlCommand objCommand = new
SqlCommand("Lea dAssignmentList ", objConnection);
objCommand.Comm andType = CommandType.Sto redProcedure;
SqlParameter prmJobRoleKey = new
SqlParameter("@ JobRoleKey", SqlDbType.Int, 4);
prmJobRoleKey.V alue = intJobRoleKey;
objCommand.Para meters.Add(prmJ obRoleKey);
// try
// {
SqlDataReader result =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection);
//populate datagrid
dgLeadAssignmen t.DataSource = result;
dgLeadAssignmen t.DataBind();
GetUserList();
imgKey.Visible = true;
btnAssignLeads. Visible = true;
dgLeadAssignmen t.Visible = true;
// }
// catch
// {
// }
}
else
{
imgKey.Visible = false;
btnAssignLeads. Visible = false;
dgLeadAssignmen t.Visible = false;
lblTotalUnassig ned.Text = "Total unassigned leads : " +
intTotalRows.To String();
}
*** Sent via Developersdex http://www.developersdex.com ***
sources' on the DataBind line in my code below. I have stepped through
and there are records in the data reader...in fact this code has been
working for over a year and has just now starting to give this error.
Can anybody help?
private void BindData()
{
string strLeadAssignme ntCount = "";
SqlConnection objConnection = new
SqlConnection(C onfigurationSet tings.AppSettin gs["constr"]);
objConnection.O pen();
//get row count
switch (intJobRoleKey)
{
//admin
case 2:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0";
break;
//CI
case 5:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 1";
break;
//DC
case 6:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 2";
break;
//Brokers
case 7:
strLeadAssignme ntCount = "select count(*) ";
strLeadAssignme ntCount += "from atradius_stagin g
where assigned = 0 and leadtypekey = 3";
break;
default:
Response.Redire ct("default.asp x");
break;
}
SqlCommand objCommandCount = new
SqlCommand(strL eadAssignmentCo unt, objConnection);
int intTotalRows =
Convert.ToInt32 (objCommandCoun t.ExecuteScalar ());
if (intTotalRows 0)
{
//now populate datareader with actual data
SqlCommand objCommand = new
SqlCommand("Lea dAssignmentList ", objConnection);
objCommand.Comm andType = CommandType.Sto redProcedure;
SqlParameter prmJobRoleKey = new
SqlParameter("@ JobRoleKey", SqlDbType.Int, 4);
prmJobRoleKey.V alue = intJobRoleKey;
objCommand.Para meters.Add(prmJ obRoleKey);
// try
// {
SqlDataReader result =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection);
//populate datagrid
dgLeadAssignmen t.DataSource = result;
dgLeadAssignmen t.DataBind();
GetUserList();
imgKey.Visible = true;
btnAssignLeads. Visible = true;
dgLeadAssignmen t.Visible = true;
// }
// catch
// {
// }
}
else
{
imgKey.Visible = false;
btnAssignLeads. Visible = false;
dgLeadAssignmen t.Visible = false;
lblTotalUnassig ned.Text = "Total unassigned leads : " +
intTotalRows.To String();
}
*** Sent via Developersdex http://www.developersdex.com ***