G
Guest
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(string LastName, string Email, string Confirmed,
string Shipped, string FromDate, string ToDate)
{
System.Data.DataSet reader = new DataSet("Requests");
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.Collections.Hashtable parms = new Hashtable();
_ListData = new PagedDataSource();
_ListData.AllowPaging = true;
_ListData.PageSize = 25;
reader = SqlHelper.ExecuteDataset(_ConnString,
System.Data.CommandType.Text, SQL + WHERE, GetParams(parms));
_ListData.DataSource = 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.DataSource = _ListData;
dlRequests.DataBind();
}
private void dlRequests_EditCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlRequests.EditItemIndex = e.Item.ItemIndex;
GetRequests(txtLast.Text, txtEmail.Text, rblConfirmed.SelectedValue,
rblShipped.SelectedValue, txtFromDate.Text, txtToDate.Text);
}
private void dlRequests_CancelCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlRequests.EditItemIndex = -1;
GetRequests(txtLast.Text, txtEmail.Text, rblConfirmed.SelectedValue,
rblShipped.SelectedValue, txtFromDate.Text, txtToDate.Text);
}
Any thoughts on what I'm doing wrong here?
Thanks
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(string LastName, string Email, string Confirmed,
string Shipped, string FromDate, string ToDate)
{
System.Data.DataSet reader = new DataSet("Requests");
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.Collections.Hashtable parms = new Hashtable();
_ListData = new PagedDataSource();
_ListData.AllowPaging = true;
_ListData.PageSize = 25;
reader = SqlHelper.ExecuteDataset(_ConnString,
System.Data.CommandType.Text, SQL + WHERE, GetParams(parms));
_ListData.DataSource = 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.DataSource = _ListData;
dlRequests.DataBind();
}
private void dlRequests_EditCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlRequests.EditItemIndex = e.Item.ItemIndex;
GetRequests(txtLast.Text, txtEmail.Text, rblConfirmed.SelectedValue,
rblShipped.SelectedValue, txtFromDate.Text, txtToDate.Text);
}
private void dlRequests_CancelCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlRequests.EditItemIndex = -1;
GetRequests(txtLast.Text, txtEmail.Text, rblConfirmed.SelectedValue,
rblShipped.SelectedValue, txtFromDate.Text, txtToDate.Text);
}
Any thoughts on what I'm doing wrong here?
Thanks