[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?
Quote:
GridView1.DataSource = mySqlDataSet.Tables("JobListTable")
GridView1.DataBind()
Re: GridView and changing row height
Hi Snufse,
Did you try the GridView's height property? It should do the trick...
HTH,
HoraShadow
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.
Quote:
OnSorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand" onRowDataBound = "GridView1_RowDataBound">
Quote:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
e.Row.Height = Unit.Pixel(5)
End Sub
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.
1 Attachment(s)
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" />
Re: GridView and changing row height
Got it working, had to remove fixed "Height" on GridView.