473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2723
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hal Vaughan | last post by:
I have a JComboBox with a list of numbers, from 1 digit to 5 digits. Numbers with more than 3 digits have a comma in them. I've been aligning them with leading spaces. Is there any simple and...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
2
by: Jan Limpens | last post by:
hi folks, which is the best way to get to the datasource/row via a bound datagrid? my datagrid is bound to a dataview. when i select a button in the grid i want easy access to the...
0
by: Danny | last post by:
I am trying to sort my second datagrid. And it works but only after i click 2 times on the column header. The first time i click on the header the data in the right order will add to the rows in...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
1
by: Jennifer | last post by:
I have a datagrid where I am trying to align some columns to the center. The rest should be aligned to the right. When I try the code below I get an error message saying that the index is out of...
1
by: nemo | last post by:
I'm creating a datasource and populating a datagrid at runtime. The code is as follows: dt = New DataTable dt.Columns.Add(New DataColumn("Item", GetType(String))) dt.Columns.Add(New...
5
by: Coleen | last post by:
Hi all :-) We are using a DB2 database connection through a class module to get the data into a datagrid in an aspx web page using VB.Net. I can get the data into the first datagrid with no...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.