473,320 Members | 1,865 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,320 software developers and data experts.

Adding paging to a Gridview Control bound to DirectoryInfo.GetFiles()

Hi,

I've bound a Gridview control to the GetFiles method

Here is a code snippet:

DirectoryInfo objDi = new
DirectoryInfo(Server.MapPath("./somepath"));

FileInfo[] arrFileInfo = objDi.GetFiles();
GridView2.DataSource = arrFileInfo;
GridView2.DataBind();

The GridView has 1 defined BoundField - "Name"

I've enabled pageing, but when I click on a page number I get the
following message:

The GridView 'GridView2' fired event PageIndexChanging which wasn't
handled

I understand that I need to handle the event.

However I don't know how to increment the index of the datasource to
the appropriate index to show the next page's values (ie Show the next
10 values)

Any help would be appreciated. Please show example code if you have
any.

Thanks.

Dec 7 '05 #1
2 4598
If I understand correctly, I think, If you use the following statement in
your pageindexchanged event handler. it should work.

GridView2.CurrentPageIndex = e.NewPageIndex;

where e is the DataGridPageChangedEventArgs.

--
Thanks
Kiran Kumar Pinjala
"pi******@hotmail.com" wrote:
Hi,

I've bound a Gridview control to the GetFiles method

Here is a code snippet:

DirectoryInfo objDi = new
DirectoryInfo(Server.MapPath("./somepath"));

FileInfo[] arrFileInfo = objDi.GetFiles();
GridView2.DataSource = arrFileInfo;
GridView2.DataBind();

The GridView has 1 defined BoundField - "Name"

I've enabled pageing, but when I click on a page number I get the
following message:

The GridView 'GridView2' fired event PageIndexChanging which wasn't
handled

I understand that I need to handle the event.

However I don't know how to increment the index of the datasource to
the appropriate index to show the next page's values (ie Show the next
10 values)

Any help would be appreciated. Please show example code if you have
any.

Thanks.

Dec 7 '05 #2
Thank you Kiran it helped me in the right direction.

The only thing that was missing was to rebind the data to the datagrid.
Once I did that it appeared to work.
But you have to do the Index change before the rebind.

So the code would be:
GridView2.PageIndex = e.NewPageIndex;
//Datasource Code here - probably a "bindit()" function
GridView2.DataBind();

Dec 7 '05 #3

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

Similar topics

2
by: dSchwartz | last post by:
I need help adding a column to a dataset, but its a little bit more complicated then just that. Here's the situation: I have many xml files in one directory, each which represent a newsletter. I...
3
by: xenophon | last post by:
This following innocuous code: System.IO.DirectoryInfo fff = new System.IO.DirectoryInfo(); System.IO.FileInfo ppp = fff.GetFiles( Request.MapPath(".") ); for( int ccc=0 ; ccc < ppp.Length ;...
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
2
by: | last post by:
Hello, I have a GridView in my ASP.NET 2.0 application that performs the paging feature perfect when I have it bound to a data source. But now I have it bound to a dataset and the paging...
3
by: mazdotnet | last post by:
Hi everyone, I know when you enable paging in a datagrid the entire data is read but only the data that you want is displayed to the end user. Has this changed for Gridview? So if you have 10000...
8
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
8
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I am trying to get a list of files from a specified directory using the System.IO namespace classes, and then use that list as the datasource for a GridView. I have been able to do this...
16
by: pupilstuff | last post by:
hi guys i just want to perform custom paging in which at the footer of the grid view ,there must be a pager 'pervious/next with numeric' this is what i did in aspx page <asp:GridView...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.