Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Align table columns with gridview columns (http://www.velocityreviews.com/forums/t382783-align-table-columns-with-gridview-columns.html)

Jacksm 11-21-2006 02:11 AM

Align table columns with gridview columns
 
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


Eliyahu Goldin 11-21-2006 08:10 AM

Re: Align table columns with gridview columns
 
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" <ftwomey@gmail.com> wrote in message
news:1164075088.947230.98200@h54g2000cwb.googlegro 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
>




Paul Chalekian 11-21-2006 09:49 PM

Re: Align table columns with gridview columns - Setting?
 
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" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.org> wrote in
message news:u7c%23$TUDHHA.3536@TK2MSFTNGP02.phx.gbl...
> 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" <ftwomey@gmail.com> wrote in message
> news:1164075088.947230.98200@h54g2000cwb.googlegro 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
> >

>
>





All times are GMT. The time now is 10:32 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.