M
Mike P
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 strLeadAssignmentCount = "";
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["constr"]);
objConnection.Open();
//get row count
switch (intJobRoleKey)
{
//admin
case 2:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0";
break;
//CI
case 5:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 1";
break;
//DC
case 6:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 2";
break;
//Brokers
case 7:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 3";
break;
default:
Response.Redirect("default.aspx");
break;
}
SqlCommand objCommandCount = new
SqlCommand(strLeadAssignmentCount, objConnection);
int intTotalRows =
Convert.ToInt32(objCommandCount.ExecuteScalar());
if (intTotalRows > 0)
{
//now populate datareader with actual data
SqlCommand objCommand = new
SqlCommand("LeadAssignmentList", objConnection);
objCommand.CommandType = CommandType.StoredProcedure;
SqlParameter prmJobRoleKey = new
SqlParameter("@JobRoleKey", SqlDbType.Int, 4);
prmJobRoleKey.Value = intJobRoleKey;
objCommand.Parameters.Add(prmJobRoleKey);
// try
// {
SqlDataReader result =
objCommand.ExecuteReader(CommandBehavior.CloseConnection);
//populate datagrid
dgLeadAssignment.DataSource = result;
dgLeadAssignment.DataBind();
GetUserList();
imgKey.Visible = true;
btnAssignLeads.Visible = true;
dgLeadAssignment.Visible = true;
// }
// catch
// {
// }
}
else
{
imgKey.Visible = false;
btnAssignLeads.Visible = false;
dgLeadAssignment.Visible = false;
lblTotalUnassigned.Text = "Total unassigned leads : " +
intTotalRows.ToString();
}
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 strLeadAssignmentCount = "";
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["constr"]);
objConnection.Open();
//get row count
switch (intJobRoleKey)
{
//admin
case 2:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0";
break;
//CI
case 5:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 1";
break;
//DC
case 6:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 2";
break;
//Brokers
case 7:
strLeadAssignmentCount = "select count(*) ";
strLeadAssignmentCount += "from atradius_staging
where assigned = 0 and leadtypekey = 3";
break;
default:
Response.Redirect("default.aspx");
break;
}
SqlCommand objCommandCount = new
SqlCommand(strLeadAssignmentCount, objConnection);
int intTotalRows =
Convert.ToInt32(objCommandCount.ExecuteScalar());
if (intTotalRows > 0)
{
//now populate datareader with actual data
SqlCommand objCommand = new
SqlCommand("LeadAssignmentList", objConnection);
objCommand.CommandType = CommandType.StoredProcedure;
SqlParameter prmJobRoleKey = new
SqlParameter("@JobRoleKey", SqlDbType.Int, 4);
prmJobRoleKey.Value = intJobRoleKey;
objCommand.Parameters.Add(prmJobRoleKey);
// try
// {
SqlDataReader result =
objCommand.ExecuteReader(CommandBehavior.CloseConnection);
//populate datagrid
dgLeadAssignment.DataSource = result;
dgLeadAssignment.DataBind();
GetUserList();
imgKey.Visible = true;
btnAssignLeads.Visible = true;
dgLeadAssignment.Visible = true;
// }
// catch
// {
// }
}
else
{
imgKey.Visible = false;
btnAssignLeads.Visible = false;
dgLeadAssignment.Visible = false;
lblTotalUnassigned.Text = "Total unassigned leads : " +
intTotalRows.ToString();
}