469,572 Members | 1,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Datagrid - Aligning Items

Hello all,

I need to know if you can vertically align Items within an
ItemTemplate. For example I have two columns, one column
has a stack of 6 textboxes, my second column can have 1 to
n number of textboxes, but when there is only one textbox
I need to be able to anchor it to the top of the column,
at present it centers itself in the middle. Does anyone
have any idea how to accomplish this?

Cheers!

Dave
Nov 17 '05 #1
2 2595
Hi Dave,

You can set all the cells in your datagrid to be top aligned by defining it
for the items style (if you have alternating styles or edit or select, then
add it there too).
<ItemStyle VerticalAlign="Top"></ItemStyle>

You can also set it for specific cells in the grid's ItemDataBound event.
The following sets top alignment for every cell in the the second column
(the first cell is zero).

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
e.Item.Cells(1).VerticalAlign = VerticalAlign.Top
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computerís security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Dave" <an*******@discussions.microsoft.com>
Sender: "Dave" <an*******@discussions.microsoft.com>
Subject: Datagrid - Aligning Items
Date: Wed, 12 Nov 2003 05:40:19 -0800
Lines: 13
Message-ID: <0d****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOpIoOPIldqSXe8RgiQi6+I+XaL1A==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190336
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello all,

I need to know if you can vertically align Items within an
ItemTemplate. For example I have two columns, one column
has a stack of 6 textboxes, my second column can have 1 to
n number of textboxes, but when there is only one textbox
I need to be able to anchor it to the top of the column,
at present it centers itself in the middle. Does anyone
have any idea how to accomplish this?

Cheers!

Dave


Nov 17 '05 #2
Thank you very much, that is just what I needed

Dave
-----Original Message-----
Hi Dave,

You can set all the cells in your datagrid to be top aligned by defining itfor the items style (if you have alternating styles or edit or select, thenadd it there too).
<ItemStyle VerticalAlign="Top"></ItemStyle>

You can also set it for specific cells in the grid's ItemDataBound event.The following sets top alignment for every cell in the the second column(the first cell is zero).

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridItemEventArgs ) Handles
DataGrid1.ItemDataBound
e.Item.Cells(1).VerticalAlign = VerticalAlign.Top
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit thehttp://www.microsoft.com/protect site and perform the three straightforwardsteps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Dave" <an*******@discussions.microsoft.com>
Sender: "Dave" <an*******@discussions.microsoft.com>
Subject: Datagrid - Aligning Items
Date: Wed, 12 Nov 2003 05:40:19 -0800
Lines: 13
Message-ID: <0d****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOpIoOPIldqSXe8RgiQi6+I+XaL1A==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190336 NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello all,

I need to know if you can vertically align Items within an ItemTemplate. For example I have two columns, one column has a stack of 6 textboxes, my second column can have 1 to n number of textboxes, but when there is only one textbox I need to be able to anchor it to the top of the column, at present it centers itself in the middle. Does anyone
have any idea how to accomplish this?

Cheers!

Dave


.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Hal Vaughan | last post: by
2 posts views Thread by pei_world | last post: by
4 posts views Thread by Glenn Owens | last post: by
2 posts views Thread by Jan Limpens | last post: by
reply views Thread by Danny | last post: by
9 posts views Thread by tshad | last post: by
1 post views Thread by Jennifer | last post: by
1 post views Thread by nemo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.