CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.faq_frequently_asked_questions Tags:
Item Type: NewsGroup Date Entered: 1/5/2006 8:55:15 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 51 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
ranganh
Asp.Net User
Error "AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid..."1/5/2006 8:55:15 AM

0

Hi,

You may receive the error "AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection." while attempting to bind a DataGrid to a DataReader and also setting the Datagrid's AllowPaging property to True.

The error occurs since you are binding a DataReader to the DataGrid. The DataReader offers a Forward Only - Read Only access to the Data that is being retrieved from the DataSource.

Since Paging would require the ResultSet to be accesible Forward as well as Reverse (To implement the Previous / Next set of records), the DataReader cannot help in this scenario.

Even if you set the AllowCustomPaging=true, though the error disappears, you will only be able to see the first set of records and will be unable to implement the built-in paging functionality provided by the DataGrid.

The resolution for the same is to use a DataSet which offers an In memory representation of Data so that you can navigate back and forth the resultset as well as do modifications to the result set. This way you can use the built-in paging functionality in your DataGrid.

However, if you want to only use a DataReader, then you need to store all the values of the DataReader in an array etc., and write custom paging functionality to implement paging.

Thanks.


regards,
Harish

http://geekswithblogs.net/ranganh
StrongTypes
Asp.Net User
Re: Error "AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid..."1/5/2006 9:09:01 AM

0

If you would like to see an example of using a DataReader for paging or sorting, take a look at the following article:

Dynamic DataGrid Paging and Sorting Using A DataReader


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
barisergun
Asp.Net User
Re: Error "AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid..."4/23/2006 7:36:31 AM

0

Hello

The DataReaders read one-way data As I undesrtand you dynamically bind your Oracle Database to your Datagird. Try to convert oracleDataReader  to DataView. DataViews can be red 2 way and they are Compatible with AllowPaging=true

I have recently sent a Control to Asp.Net I think it is in the proccessing stage that Control converts OdbcDataReader to DataView below is the open code for you to give you an idea. You must apply the same logic to your Oracle Reader

Good Luck,

Baris ERGUN

www.thecoreopsis.com

public static DataView ConvertToDataView(OdbcDataReader setToCheck, string tableName)

{

DataTable dataReaderTable = new DataTable(tableName);

try

{

for(int h=0;h<setToCheck.FieldCount;h++)

{

DataColumn temp = new DataColumn(setToCheck.GetName(h),setToCheck.GetFieldType(h));

dataReaderTable.Columns.Add(temp);

}

while(setToCheck.Read())

{

DataRow dr = dataReaderTable.NewRow();

for(int g=0;g<setToCheck.FieldCount;g++)

{

dr[g] = setToCheck.GetValue(setToCheck.GetOrdinal(setToCheck.GetName(g)));

}

dataReaderTable.Rows.Add(dr);

}

return dataReaderTable.DefaultView;

}

catch

{

return null;

}

}

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:




   
  Privacy | Contact Us
All Times Are GMT