Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2008, 04:26 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default GridView and Row Height problem

I have a GridView that has a page size of 10. My table has 13 records that gets loaded. When I display the 1st page the GridView looks fine. Then I page to page number 2 to show the additional 3 records and the Row Height has changed (increased dramatically). Any ideas to prevent this?

 
Old January 11th, 2008, 07:37 AM
jomet
Guest
 
Posts: n/a
Default

hi,
use
<AlternatingRowStyle BackColor="White" Height="50" />

regds

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
 
Old January 11th, 2008, 08:53 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

jomet,

That did not work. The 2nd page that has 3 records still show increased row height. Is there a way to set a fixed row height regardless of how many rows are displayed on a page? By the way, I have the GridView inside a panel control, not sure if that makes a difference?

Here is the code I have:

Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="PropSale.aspx.vb" Inherits="PropSale" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    &nbsp; &nbsp; &nbsp;
    <asp:Panel ID="Panel1" runat="server" BorderColor="White" BorderStyle="Solid" Height="485px"
        Style="left: 0px; position: relative; top: -11px" Width="783px">
        <asp:Label ID="Label1" runat="server" BackColor="White" BorderStyle="None" Font-Size="X-Large"
            Style="left: 277px; border-top-style: none; border-right-style: none; border-left-style: none;
            position: relative; top: 9px; text-align: center; border-bottom-style: none"
            Text="Propellers for Sale" Width="214px" ForeColor="Red"></asp:Label>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <asp:Label ID="Label2" runat="server" Style="left: -243px; position: relative; top: 53px"
            Text="Select Diameter" Width="135px"></asp:Label>
        &nbsp;
        <asp:TextBox ID="TextBox1" runat="server" BackColor="#FFFFC0" Height="14px" Style="left: -253px;
            position: relative; top: 54px"></asp:TextBox>&nbsp;
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" BorderStyle="Solid"
            Font-Size="Small" Height="369px" Style="left: 24px; position: relative; top: 72px"
            Width="738px" AllowSorting="True"  AlternatingRowStyle-BackColor="White">
            <HeaderStyle BackColor="#C0FFFF" BorderStyle="Solid" Font-Size="Small" />
            <AlternatingRowStyle BackColor="#FFFFC0" />
        </asp:GridView>
        <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Contact.aspx" Style="left: 629px;
            position: relative; top: -337px" Width="124px">Contact us for price</asp:LinkButton>
        <asp:Button ID="Button1" runat="server" BackColor="Silver" Style="left: 204px; position: relative;
            top: -336px" Text="Search" Width="63px" />
        &nbsp; &nbsp;&nbsp;
    </asp:Panel>
</asp:Content>
 
Old January 11th, 2008, 09:46 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I found this site adevertising extended grid controls that will show blank rows to keep size consistent. Anybody used it?

http://aspalliance.com/946_Extended_GridView_Control

 
Old January 11th, 2008, 02:29 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I solved the problem following way:
Instead of having a fixed row height, I make sure that the gridview is always filled to its pagesize. I do this by taking the number of rows from the table and dividing by grid's page size. The decimal fraction is the number of rows I manually need to fill into the dataset prior to binding:

Example: If rows = 26 and page size = 10, then I need to fill 4 rows manually (26/10 = 2,6 and then 10 - 6 = 4)

Code:
'Manually fille rows, uses number of rows from table - grid page size
Dim ShortFullPage As Double = myDataSet.Tables("myDataTable").Rows.Count Mod GridView1.PageSize
Dim ManualRowsNeeded As Integer = GridView1.PageSize - ShortFullPage

Dim i As Integer
For i = 0 To ManualRowsNeeded - 1
myDataSet.Tables("myDataTable").Rows.Add(myDataSet.Tables("myDataTable").NewRow())
Next i





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjust row height of gridview wirerider ASP.NET 2.0 Basics 5 February 1st, 2008 07:01 AM
Fixed table height and row height rajanikrishna HTML Code Clinic 3 January 18th, 2007 12:42 AM
Increase row height in Excel and multiple lines in jmss66 VB How-To 4 June 23rd, 2006 05:45 AM
Fit the row height dinamically in a datagrid Lukas C# 1 June 7th, 2006 03:06 AM
Row Height aspadda Excel VBA 0 February 25th, 2004 03:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.