Results 1 to 12 of 12

Thread: Gridview page numers not displaying

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Gridview page numers not displaying

    I have a page with a couple of grids on it, one displays a list of results from a search and the other then displays details when one of the result rows is selected.
    Even though the second grid has multiple pages the page numbers are not diplaying at runtime (they can be seen in design mode) so I can't page through the information. The paging is all fine on the results grid and the properties appear the same for both grids.

    Any help would be greatly appreciated

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Without markup and code info, we cannot help.A quick thought thought. If your second grid display details from the selected row on the first, is it possible that the second grid has not reached the page max provided, to go to a new page?I mean pagesize variable, if i am not mistaken.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Gridview page numers not displaying

    Hi,

    If I look at the gridview pagecount it's multiple, it's just not displaying the page numbers at the bottom like it should be. The results hrid lists properties and then the second grid lists electors within the selected property which might only be one or two but in the case of care homes can be upwards of 30, my page size is only 5.

    This is the markup for my results grid
    <asp:Panel runat="server" ID="wpResults" BorderColor="#3A9946" BorderStyle="Solid"
    BorderWidth="1px" Width="98%" Visible="false">
    <asp:GridView ID="gvResults" runat="server" Width="98%" AutoGenerateColumns="False"
    AllowPaging="True" GridLines="None" ShowHeader="false" DataKeyNames="ID">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:Image ID="imgRow" runat="server"></asp:Image>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Type" />
    <asp:BoundField DataField="ID" />
    <asp:BoundField DataField="ElectorName" />
    <asp:BoundField DataField="Ref" />
    <asp:BoundField DataField="Address" />
    </Columns>
    <PagerStyle BorderStyle="None" Font-Names="Trebuchet MS" Font-Size="X-Small" ForeColor="#3A9946"
    HorizontalAlign="Center" />
    <RowStyle BackColor="#E3F1E5" />
    <AlternatingRowStyle BackColor="#84CA98" />
    <SelectedRowStyle Font-Size="Small" />
    </asp:GridView>
    <br />
    </asp:Panel>

    And this is the markup for the Electors grid
    <asp:Panel runat="server" ID="wpPropertyElectors" BorderColor="#3A9946" BorderStyle="Solid"
    BorderWidth="1px" Width="98%" Visible="false" >
    <asp:GridView ID="gvElectors" runat="server" Width="98%" AutoGenerateColumns="False" ShowHeader="false"
    AllowPaging="True" GridLines="None" DataKeyNames="ID" PageSize="5" >
    <Columns>
    <asp:BoundField DataField="ID" ItemStyle-Width="3%" >
    <ItemStyle Width="3%" />
    </asp:BoundField>
    <asp:BoundField DataField="Elector" ItemStyle-Width="50%" >
    <ItemStyle Width="50%" />
    </asp:BoundField>
    <asp:BoundField DataField="Number" ItemStyle-Width="15%" >
    <ItemStyle Width="15%" />
    </asp:BoundField>
    <asp:BoundField DataField="Markers" ItemStyle-Width="15%" >
    <ItemStyle Width="15%" />
    </asp:BoundField>
    <asp:BoundField DataField="Status" ItemStyle-Width="20%" >
    <ItemStyle Width="20%" />
    </asp:BoundField>
    </Columns>
    <PagerStyle BorderStyle="None" Font-Names="Trebuchet MS" Font-Size="Large" ForeColor="#3A9946"
    HorizontalAlign="Center" />
    <RowStyle BackColor="#E3F1E5" />
    <AlternatingRowStyle BackColor="#84CA98" />
    <SelectedRowStyle Font-Size="Small" />
    </asp:GridView>
    <br />
    </asp:Panel>

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Hi.So if you have more than 5 rows what happens to the gridview?Do you see and extra 6th row on the same page or it's not displayed at all?Can you show the vb code when you bind your data?
    Also try removing the panel, for a quick test.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Gridview page numbers not displaying

    Even without the panel its the same, doesn't matter how many records are returned from the database it only shows the first 5. If I break after the bind and check the number of pages in the gridview it has multiple but the page numbers are not displaying on screen so I can't page through.

    Private Sub BindElectors()
    Try
    gvElectors.Visible = True
    gvElectors.DataSource = PropertyElectors
    gvElectors.DataBind()

    Catch ex As Exception
    Throw
    End Try
    End Sub

    PropertyElectors is a DataTable

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Hi.At first leave the gridview visible on markup and remove the visible=true from code.Also you should check your dataset rows to confirm that they are more than 5.If they are then trry setting the gridview alone with the absolute minimum:
    Code:
    <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False"
    AllowPaging="True"  DataKeyNames="ID"/>
    If again nothing then create a new page and do a databind on a new gridview with your datatable to see if it works in the first place.
    Ah, also remove the paging option as a test to make sure that they data comes over 5 rows.
    Also if there is any jscript of other code you haven't shown and effects the gridview, do so.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Gridview page numbers not displaying

    Not being a complete novice I have tried the obvious suggestions you have proposed and am looking for something a bit less obvious that I may have missed.

    I know my datatable has 20+ rows, I know my gridview has 6+ pages as I put a breakpoint in the code to check. There is no jscript affecting the gridview it is just a simple display for selection. As I said previously I have another grid that is set the same and works fine so it is very puzzling.

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Ok, then make a new page and use only the problematic gridview.As soon as you see that it works then bring along the first gridview.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Gridview page numbers not displaying

    I did as you advised and the new page shows the page numbers. I then removed everything from the original page except the search and results functionality and I've attached a screenshot of the results but essentially the grid on the same page shows oPaging.docRegisterDetails.zipnly 5 results but the new page shows the same 5 records and page numbers!

    I've attached the new code files as well, hopefully that will help you see what I've missed

  10. #10
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Sorry, can't look all the code for you, you have to do it yourself.Anyhow with just a quick look i see that you set the grid pagesize in markup and then you have a function in code that set's the pagesize according to height. What is the correct?
    Also did you write this code by yourself?Do you know what it does,exactly?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  11. #11

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Gridview page numers not displaying

    If you'd looked at the code properly you would've have seen that the page size set routine is for the results gridview not the electors one! Of course I wrote it myself and know exactly what it does...I sent the code in the hope that you would help me not patronise and be rude to me. If you don't know then you don't know...just admit it and move on.

  12. #12
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Gridview page numers not displaying

    Huh?When was i rude?I explained that you can't just shoot 2000 code lines and expect me to read it.You have to pinpoint the problem.Anyhow, i admit that i don't know and i move on.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width