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