Solved

Gridview with paging disappears when you select the next page?!?!?

Posted on 2006-11-14
4
1,080 Views
Last Modified: 2009-12-16
I have a gridview in my asp.net 2.0 application:  (details below):

the gridvidew is populated by a datasource.
Paging is enabled.
When the page is loaded, it appears without any trouble.  then when i try to select page 2, 3 or 4 etc, the gridview disappears!!!!!!
any help would be much appreciated? I can't figure out why this is happening?!?!?
I have no code behind the gridview........
PLEASE HELP :-)

here are the details of the gridview......

     <asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4" DataSourceID="SqlDataSource1"
                        ForeColor="#333333" GridLines="None" Height="55px" PageSize="6" Style="z-index: 114;
                        left: 233px; position: absolute; top: 298px" Visible="True" Width="756px">
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <EditRowStyle BackColor="#999999" />
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    </asp:GridView>
0
Comment
Question by:ciara_barry123
  • 2
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:badalpatel
badalpatel earned 500 total points
ID: 17937278
i cant figure out whats happening coz this code works fine for me..
i think this must be in ur page load event where u r making gridview visible property to false...
can u post ur page load event code??
0
 

Author Comment

by:ciara_barry123
ID: 17937287
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ShowCalendar(ImageButton9, TextBox1)
        ShowCalendar(ImageButton10, TextBox2)
        If FirstTimeLoad <> False Then
            Me.CategoryList.Items.Insert(0, New ListItem("ALL", "ALL"))
            Me.CategoryList.SelectedIndex = 0
            FirstTimeLoad = False
        End If
    End Sub

so..nothnig in there to do with the gridview
the showcalendar function has nothing to do with it....

I'm stumped!
0
 
LVL 6

Accepted Solution

by:
badalpatel earned 500 total points
ID: 17937307
<form id="form1" method="post" runat="server">
     <asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4" DataSourceID="SqlDataSource1"
                        ForeColor="#333333" GridLines="None" Height="55px" PageSize="6" Style="z-index: 114;
                        left: 233px; position: absolute; top: 298px" Visible="True" Width="756px">
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <EditRowStyle BackColor="#999999" />
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AIM_finalConnectionString %>"
            SelectCommand="SELECT [Trigger_RecID], [TriggerID], [TriggerName], [TriggerTime], [LocationID], [Value], [ParameterID] FROM [CHALMETTE_TRIGGER_RECORD]">
        </asp:SqlDataSource>
    </form>

i have this code and its works fine on my pc..so what to do next?check the sqldatasource.
0
 

Author Comment

by:ciara_barry123
ID: 17939472
Hi badalpatel
I figured it out
the query to populate the sqldatasource was generated when a button was pressed.
i built up a string and set the string as the selectcommand of the sqldatasource.
it was a global variable.
so when paging was disabled it all worked fine as the page wasn't reloaded
when I enabled paging  - when the gridview was clicked, the global variable became empty and thus the gridview was invisible

I will have to use session variables instead of a global variable and it should all work fine..
thanks for the help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question