IListSource does not contain any data

Discussion in 'ASP .Net' started by Mike P, Jan 31, 2007.

  1. Mike P

    Mike P Guest

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


    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Jan 31, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. troutbum
    Replies:
    1
    Views:
    4,649
    =?Utf-8?B?S2VuIENveCBbTWljcm9zb2Z0IE1WUF0=?=
    Oct 6, 2004
  2. Replies:
    2
    Views:
    6,897
  3. Assimalyst
    Replies:
    10
    Views:
    3,667
    Assimalyst
    Jul 8, 2005
  4. =?Utf-8?B?V2FsaWQ=?=

    The IListSource does not contain any data sources.

    =?Utf-8?B?V2FsaWQ=?=, Sep 13, 2007, in forum: ASP .Net
    Replies:
    10
    Views:
    1,160
  5. KK
    Replies:
    1
    Views:
    288
    Srimathi
    Jan 13, 2005
Loading...

Share This Page