Datagrid - Aligning Items

D

Dave

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
 
M

Mike Moore [MSFT]

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.


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top