Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Align table columns with gridview columns

Reply
Thread Tools

Align table columns with gridview columns

 
 
Jacksm
Guest
Posts: n/a
 
      11-21-2006
How can I align an asp:table columns with gridview columns (the
widths)? I have tried setting table.column(0).width =
gridview.column(0).width at page_load but it doesn't work.

Thanks in advance

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      11-21-2006
This is not possible since the ultimate control on column width is in the
browser hands and your instructions are treated as recommendations. You have
to merge the table and the gridview content into the same control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"Jacksm" <> wrote in message
news: ups.com...
> How can I align an asp:table columns with gridview columns (the
> widths)? I have tried setting table.column(0).width =
> gridview.column(0).width at page_load but it doesn't work.
>
> Thanks in advance
>



 
Reply With Quote
 
 
 
 
Paul Chalekian
Guest
Posts: n/a
 
      11-21-2006
I have a very similar problem. In using a datagrid, I can dynamically change
the column formatting/justification in Debug. But when deployed to our
Intranet server, this formatting goes away and reverts to the default (left
justified). Is this a setting issue?

Specifically, I need

some text columns justified into the center and

some $ amount columns justified to the right

On a Button:

Private Sub btnReport2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnReport2.Click

Dim ls_locn_id As String = ""

Dim ls_make As String = ""

Dim ls_Amt As String = ""

' //Define a DataRow

Dim dr_comments As DataRow

' //Define the DataColumns.

dt_comments.Columns.Add(New DataColumn("LOCN", GetType(String)))

dt_comments.Columns.Add(New DataColumn("MAKE", GetType(String)))

dt_comments.Columns.Add(New DataColumn("AMT", GetType(String)))

dr_comments = dt_comments.NewRow()

ls_locn_id = "Central"

ls_make = "Right-justified"

ls_Amt = "10.00"

dr_comments(0) = ls_locn_id

dr_comments(1) = ls_make

dr_comments(2) = ls_Amt

' //Add the data to the row now.

dt_comments.Rows.Add(dr_comments)

End If

End While

objreader.Close()

dgSurveyResults.DataSource = dt_comments

dgSurveyResults.DataBind()

btnReport1.Enabled = True

End Sub



After the button:

Private Sub dgSurveyResults_ItemDataBound(ByVal sender As Object,

ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

Handles dgSurveyResults.ItemDataBound

Try

Dim item As DataGridItem = CType(e.Item, DataGridItem)

Dim i As Integer = e.Item.ItemIndex

With item

..Cells(0).HorizontalAlign = HorizontalAlign.Center

..Cells(1).HorizontalAlign = HorizontalAlign.Right

..Cells(2).HorizontalAlign = HorizontalAlign.Right

End With

Catch tex As Threading.ThreadAbortException

Catch ex As Exception

Response.Write(ex.Message & ex.StackTrace)

Finally

End Try

End Sub



Incidentally:

No error is thrown but with diagnostics in place the innermost code is
executing.

The operating systems of both my development system and the host server
are Windows 2000.

Another (possible) clue is that

the color of my development system shows Blue text, but

the color of the server-based text is Purple.

Great thanks in advance,

Puzzled

"Eliyahu Goldin" <> wrote in
message news:u7c%23$...
> This is not possible since the ultimate control on column width is in the
> browser hands and your instructions are treated as recommendations. You

have
> to merge the table and the gridview content into the same control.
>
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]
>
>
> "Jacksm" <> wrote in message
> news: ups.com...
> > How can I align an asp:table columns with gridview columns (the
> > widths)? I have tried setting table.column(0).width =
> > gridview.column(0).width at page_load but it doesn't work.
> >
> > Thanks in advance
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div align=center> also affects align of dynamic dropdown item text Steve Richter ASP .Net 1 06-24-2007 07:11 PM
left align within centre align Paul Lautman HTML 3 03-03-2006 02:45 PM
text-align vs align tshad HTML 1 06-23-2005 10:29 PM
How to align right a table based on another table created dinamically? Leonardo Gangemi ASP .Net 0 04-07-2004 01:11 PM
how to Align text left & vertical align middle Kay ASP .Net 2 07-25-2003 08:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57