[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 736
  • Last Modified:

Why are my Paging controls not visible at runtime in my ASP.net GridView control?

Hi:

I'm trying to implement an ASP.net GridView control with paging. A lot of descriptions indicate that by setting a couple of quick properties, paging will "just work."

The issue I have is that the paging controls are not displaying at the bottom of my GridView.
I see them in VS Designer.

When I inspect the generated table in the browser debugger, I see that an empty row <tr> has
been created at the last row in the generated table (presumably this is where the paging controls will be inserted).

Here is the HTML gridview definition:
<asp:gridview id="gvMasters1" runat="server" cssclass="tblMasterDetail" AutoGenerateColumns="False" 
   CellPadding="0"  pagerstyle-mode="NumericPages" pagerstyle-pagebuttoncount="20" PageSize="5" 
   EnableViewState="true" AllowPaging="True" PagerSettings-PreviousPageText="Previous Page" 
   PagerSettings-NextPageText="Next Page" PagerSettings-Mode="NextPreviousFirstLast" 
   PagerSettings-LastPageText="Last Page" PagerSettings-FirstPageText="First Page" 
   ClientIDMode="Static" allowsorting="True" visible="True">
       <headerstyle cssclass="HeaderStyle" />
       <alternatingrowstyle cssclass="AlternatingRowStyle" />
       <selectedrowstyle cssclass="SelectedRowStyle" />
</asp:gridview>

Open in new window


I'm using a DataTable as my GridView datasource.
Here is a snapshot of my codebehind:
 gvMasters.AutoGenerateColumns = True
        dvMasters = dtMasters.DefaultView
        Dim strKeys() = {"TxnID"}
        gvMasters.DataKeyNames = strKeys
        gvMasters.DataSource = dvMasters

        ' If return results are empty, we still want to display columns
        If dtMasters.Rows.Count <= 0 Then
            dtMasters.Rows.Add(dtMasters.NewRow())
            isEmpty = True
        End If

        gvMasters.DataBind()

        If isEmpty Then
            gvMasters.Rows(0).Visible = False
            gvMasters.Rows(0).Controls.Clear()
        End If

        gvMasters.Visible = True

Open in new window


I have spent several hours trying to figure this out.
What am I doing wrong/missing here?
Can someone point me in the right direction?

Thanks,
JohnB
0
jxbma
Asked:
jxbma
1 Solution
 
jxbmaSoftware ConsultantAuthor Commented:
Figured it out.
I was setting a cell's visibility instead of using CSS class display to do so.

JB
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now