By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,893 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

IListSource does not contain any data

P: n/a
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.CloseConn ection);

//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();
}

*** Sent via Developersdex http://www.developersdex.com ***
Jan 31 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.