Results 1 to 6 of 6

Thread: [Resolved] GridView and changing row height

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    [Resolved] GridView and changing row height

    I have a GridView set to fill 15 rows per page. If I have less than 15 rows the row height changes. Is there a way to have row height be constant and not change.

    I have temporarily solved this by filling blank rows at the end if less than 15 and this works ok untill I need to sort. Then blank rows shows up.

    I have read that I possible could use RowDataBound event, if this is the case, how does that fit into the following code, when and where a hook up to that event?

    GridView1.DataSource = mySqlDataSet.Tables("JobListTable")
    GridView1.DataBind()
    Last edited by snufse; May 19th, 2008 at 10:00 AM.

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: GridView and changing row height

    Hi Snufse,

    Did you try the GridView's height property? It should do the trick...

    HTH,
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  3. #3

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: GridView and changing row height

    Tried to set the height property for the Header as well as for the Row Style. If I have less that 15 lines (which is the pages size), the row height adjusts itself. I aslo tried this and still row height changes.



    OnSorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand" onRowDataBound = "GridView1_RowDataBound">

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

    e.Row.Height = Unit.Pixel(5)

    End Sub
    Last edited by snufse; May 16th, 2008 at 11:33 AM.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: GridView and changing row height

    Give the rows a fixed height by setting Height="5" (or whatever you want) in the <RowStyle> property of the Gridview.

  5. #5

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: GridView and changing row height

    Attached is the result from setting the "RowStyle: poperty Height = 6.

    Still the rowheight changes according to how many lines are found.

    Code:
    <asp:GridView ID="GridView1" runat="server" Height="505px" Style="z-index: 10; left: -7px;
                position: absolute; top: 85px; border-right: gray thin solid; border-top: gray thin solid; border-left: gray thin solid; border-bottom: gray thin solid;" Width="902px" AllowPaging="True" AllowSorting="True" Font-Size="Small" PageSize="15" AutoGenerateColumns="False" CellSpacing="2" HorizontalAlign="Left" BorderColor="LightGray" BorderStyle="None" 
                OnSorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand" onRowDataBound = "GridView1_RowDataBound">
                <PagerSettings PageButtonCount="15" />
                <RowStyle Height="5px" />
                <HeaderStyle BackColor="#FFE0C0" Height="6px" HorizontalAlign="Left" VerticalAlign="Middle" />
                <AlternatingRowStyle BackColor="#FFFFC0" />
    Attached Files Attached Files
    Last edited by snufse; May 19th, 2008 at 07:06 AM.

  6. #6

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: GridView and changing row height

    Got it working, had to remove fixed "Height" on GridView.

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