Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

view gridview every 20 pages

view gridview every 20 pages

view gridview every 20 pages

Hi guys,

I am trying to view the list of tables which contains thousand of records to do viewing page every 20 pages and here's what I have been trying

asp.net code


<asp:GridView ID="GridRefTable" runat="server" CssClass="mword" EnableViewState ="false" HeaderStyle-CssClass="viewprpstatustablehead"
                PagerSettings-Mode="NextPrevious" PageSize ="20" CellSpacing="0" CellPadding="5" PagerSettings-Visible="true" AllowPaging ="true"  />

cs code


        private void View_Table()
            RefTable = DropDownListRefTables.SelectedItem.Value;

            SqlConnection conn = new SqlConnection(CONST_CONN);

            String sql = "select top 100 * from " + RefTable;

            SqlCommand cmd = new SqlCommand(sql, conn);

                if (DropDownListRefTables.SelectedItem.Value == "")
                    LabelRefTable.CssClass = "merror";
                    LabelRefTable.Text = "Please choose the reference table";
                    SqlDataReader reader = cmd.ExecuteReader();
                    GridRefTable.DataSource = reader;

            catch (Exception ex)
                LabelRefTable.CssClass = "merror";
                LabelRefTable.Text = ex.Message;

But I have got an error:
"The data source does not support server-side data paging."

I understand to collect the records from table into list collection first, but how to do dynamic list collection since I have list of many different tables which contains different number of columns?

Any input will be appreciated :)

RE: view gridview every 20 pages

Sample code

The grid code looks something like.


<asp:DataGrid runat="server" ID="dgCommunication" AutoGenerateColumns="false" AllowPaging="true" PageSize="20" AllowSorting="true" Width="900" OnPageIndexChanged="commGrid_Paging"
the code behind
protected void commGrid_Paging(object sender, DataGridPageChangedEventArgs e)
     dgCommunication.CurrentPageIndex = e.NewPageIndex;
The loadcomgrid method just requerys the datasource and binds it to the grid.
So for your example you would set the currentpageindex to 20 greater than it is now, rather than the newpageindex.. or you could set it to newpageindex+20




RE: view gridview every 20 pages

Hi NoCoolHandle,

your code about this is error


        protected void commGrid_Paging(object sender, DataGridPageChangedEventArgs e)
            GridRefTable.CurrentPageIndex = e.NewPageIndex;

Here's the error code


Error    5    'System.Web.UI.WebControls.GridView' does not contain a definition for 'CurrentPageIndex' and no extension method 'CurrentPageIndex' accepting a first argument of type 'System.Web.UI.WebControls.GridView' could be found (are you missing a using directive or an assembly reference?)

Looks like Gridview doesnt have extension CurrentPageIndex.

RE: view gridview every 20 pages

Yeah.. it might be an issue with the GridView..
I tend to like the DataGrid more as it seems to be more flexable..
I will do a quick dig and see if i can find anything for a GridView that does tthe same thing..
Sorry I missed the clue at the top the first view.



RE: view gridview every 20 pages

Hmm, this is strange...

in VS2008 DataGrid doesn't exist anymore, only GridView hence I use it.

I'll try it tomorrow as today I'm on leave.

Thanks anyway for your help NoCoolHandle

RE: view gridview every 20 pages

Now that is interesting..
You could try using intellisense to get it..
I.e. start typing <asp:Datag  and see if it fills it in.

Just for the heck of it check out this site

there is a TONE of stuff about customizing the datagrid.

Lots of other great stuff on asp.net and for that matter .net in general (silverlight etc..)

The cool thing is it is full of examples C# and VB.

Enjoy the next few  days off..


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close