Datalist Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ENIZIN

    Datalist Error

    I am having an issue with a pageable Datalist object. I can page through it
    just fine using the PagedDataSource object but when I try and click my edit
    button I get the error:

    "Invalid attempt to FieldCount when reader is closed"

    Now I know typically you get this if the datareader is closed but from what
    I can tell mine is not. On each command event I reload the list to show the
    currently updated data. If I click edit then cancel and then try and edit
    again I get that error. Sometimes I don't even make it that far.

    Here is a snipped of what's going on:

    //my function to load the data - it's been trimmed down for simplicity
    private void GetRequests(str ing LastName, string Email, string Confirmed,
    string Shipped, string FromDate, string ToDate)
    {
    System.Data.Dat aSet reader = new DataSet("Reques ts");
    string SQL = "SELECT id, First_Name, Last_Name, Address, Address2,
    mailcode, Building, Room, " +
    "City, State, Zip, Country, Phone, LabPhone, Fax, Email, confirmed,
    shipped, Created " +
    "FROM LIT_Request";
    string WHERE = null;

    System.Collecti ons.Hashtable parms = new Hashtable();

    _ListData = new PagedDataSource ();
    _ListData.Allow Paging = true;
    _ListData.PageS ize = 25;

    reader = SqlHelper.Execu teDataset(_Conn String,
    System.Data.Com mandType.Text, SQL + WHERE, GetParams(parms ));

    _ListData.DataS ource = reader.Tables[0].DefaultView;
    SetPagingInfo() ;

    /*
    When I get here I have around 750 rows in my dataset but still once the
    DataBind() is called it blows up.
    */
    dlRequests.Data Source = _ListData;
    dlRequests.Data Bind();
    }

    private void dlRequests_Edit Command(object source,
    System.Web.UI.W ebControls.Data ListCommandEven tArgs e)
    {
    dlRequests.Edit ItemIndex = e.Item.ItemInde x;
    GetRequests(txt Last.Text, txtEmail.Text, rblConfirmed.Se lectedValue,
    rblShipped.Sele ctedValue, txtFromDate.Tex t, txtToDate.Text) ;
    }

    private void dlRequests_Canc elCommand(objec t source,
    System.Web.UI.W ebControls.Data ListCommandEven tArgs e)
    {
    dlRequests.Edit ItemIndex = -1;
    GetRequests(txt Last.Text, txtEmail.Text, rblConfirmed.Se lectedValue,
    rblShipped.Sele ctedValue, txtFromDate.Tex t, txtToDate.Text) ;
    }

    Any thoughts on what I'm doing wrong here?

    Thanks

Working...