Solved

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

Posted on 2006-11-14
4
1,057 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now