Coleen,
I think you have to make the change in the ItemDataBound event. Try
something like this:
Jared
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then LoadData()
End Sub
Private Sub LoadData()
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString =
"Server=localhost;Database=Northwind;Trusted_Connection=True;"
conn.Open()
Dim da As New SqlClient.SqlDataAdapter("Select TitleOfCourtesy,
FirstName, LastName, Title FROM Employees Order By FirstName", conn)
Dim ds As New DataSet
da.Fill(ds)
conn.Close()
Me.DataGrid1.DataSource = ds
Me.DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If Not e.Item.DataItem Is Nothing Then
If e.Item.ItemType = ListItemType.AlternatingItem Or
ListItemType.Item Or ListItemType.SelectedItem Then
Dim Item As DataGridItem = CType(e.Item, DataGridItem)
With Item
.Cells(0).HorizontalAlign = HorizontalAlign.Right
End With
End If
End If
End Sub
[quoted text, click to view] "Coleen" <coleenholley@yaho.com> wrote in message
news:OKkOQgBdEHA.3512@TK2MSFTNGP12.phx.gbl...
Hi all :-)
I'm back to trying to format my ASP. Net datagrids...I can format the totals
row easily enough by doing a count -1 in the VB code behind. What I need to
do is for each row, I need to set the alignment of each cell to either left
or right. In my for loop I have code to add the row:
dt_stat_report_5.Rows.Add(dr_stat_report_5)
Now for each row I need to set the alignment...can anyone please help me
with this? I've tried using:
dt_stat_report_5.Rows.Items(0).HorizontalAlign.Left - but of course this
does not work, there is not HorizontalAlign available. Can someone please
tell me a way to format the alignment in the VB Code-behind? TIA
Coleen