May 15th, 2008, 01:37 PM
#1
Thread Starter
Fanatic Member
[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 .
May 15th, 2008, 04:35 PM
#2
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 .
May 16th, 2008, 11:05 AM
#3
Thread Starter
Fanatic Member
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 .
May 16th, 2008, 02:47 PM
#4
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.
May 19th, 2008, 06:58 AM
#5
Thread Starter
Fanatic Member
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
Last edited by snufse; May 19th, 2008 at 07:06 AM .
May 19th, 2008, 10:00 AM
#6
Thread Starter
Fanatic Member
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
Forum Rules
Click Here to Expand Forum to Full Width