473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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(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

Nov 18 '05 #1
0 807

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
0
by: ani | last post by:
I have few questions regarding datalist control. 1) How do I retrieve the values that are present in the datalist control. My aspx page actually reloads to itself, and the datalist control has...
4
by: Roger R. Smith | last post by:
Anyway I am having a problem with Web Service and DataList in ASP.NET. so the best way to explain it would be with the MSPetShop 3.0 Application. I submitted an order using the Forms on...
3
by: Chris | last post by:
Hi Folks, well I have this "small" problem with the footertemplate in a datalist. I added a button and a textbox to update the db with the given String of the Textbox. I already searched for...
8
by: bienwell | last post by:
Hi, I have a problem of displaying data bound by a datalist control. In my table, I have a field Start_date which has Short Date data type. I tried to update this field by Current Date. After...
5
by: Petr SIMUNEK | last post by:
Is there a way to render something before the DATALIST encapsulation table gets rendered ? So that I could have Label before actual table that is rendered by DATALIST... <h1>Some Label</h1>...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
5
by: Vikas Kumar | last post by:
i had coded like this <ItemTemplate> <table width="100%"> <tr width="100%"> <td width="25%"><%#DataBinder.Eval(Container.DataItem,"FName")%></td> <td width="25%"><input type=text ...
2
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.