Column Widths...NOT a DATAGRID..Just A table

V

vpravin

Hi guys...i am a super noob with html and aspx..

i didnt start this project but i am modifying it...

q: how do i change the width of a column:

Thats the table which is within a text box

<asp:Table id="regulatoryDetails" runat="server" Font-Size="X-Small"
Width="400px" Height="8px"
CellPadding="0" CellSpacing="0" CssClass="regular"
HorizontalAlign="Center"></asp:Table></P>
</asp:panel><asp:panel id="Panel4" style="Z-INDEX: 103; LEFT: 16px;
POSITION: absolute; TOP: 16px" runat="server"
CssClass="regular" BorderWidth="1px" BorderStyle="Solid"
BorderColor="#463E41" Height="176px" Width="404px"
Font-Size="X-Small">
<P>











...

i went to the FAQ of this forum and saw the post about changingf
column widths...

it sent me to a KB article which asked me to do this:



Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
e.Item.Cells(0).Width = New Unit(264)
e.Item.Cells(1).Width = New Unit(264)
End Sub



....now my q is..when i call teh function..what do i put in
DataGrid1_ItemCreated(tablename, ???)

....

This is the code at the start of the program

Protected WithEvents serviceProviders As
System.Web.UI.WebControls.Table
Protected WithEvents strategyAndStyles As
System.Web.UI.WebControls.Table
Protected WithEvents details As System.Web.UI.WebControls.Table

........

thats how i add cells to the table



Dim titleCell As New TableCell, valueCell As New TableCell
titleCell.Text = strategies

titleCell.CssClass = "regular"

valueCell.Text = style

valueCell.CssClass = "regular"

'if a sort column is specified for and of the column, add the 'sorted'
css class laso to that column

If Me.regulatoryDetailsSortColumn = "Strategy" Then

titleCell.CssClass = titleCell.CssClass & " " & "sorted"

ElseIf Me.regulatoryDetailsSortColumn = "Style" Then

valueCell.CssClass = valueCell.CssClass & " " & "sorted"

End If

'create the rows for the cells created and add the rows to the
regylatory details table

Dim r As New TableRow
r.Cells.Add(titleCell)

r.Cells.Add(valueCell)

Me.strategyAndStyles.Rows.Add(r)



NOTE>...I DONT HAVE A DATAGRID in the table...
just a panel; and a table inside it..
and i add rows to it
 
V

vpravin

I have tried this and it hasnt worked not worked


"
Ok, You need to uniquly identify the two columns, by adding an
additional class:

titleCell.CssClass =titleCell.CssClass & " titlewidth"

valueCell.CssClass =valueCell.CssClass & " valuewidth"

Then in CSS add the following:

td.titlewidth{
width:100px;
}

td.valuewidth{
width:200px;
}

**UPDATE**

Its tidier to modify the code as shown below then add-in the CSS:

Dim titleCell As New TableCell, valueCell As New TableCell
titleCell.Text = strategies
titleCell.CssClass = "regular titlewidth"
valueCell.Text = style
valueCell.CssClass = "regular valuewidth"

NB: the space is important!
""
 
M

Mike

start with this and modify it as you see fit:


<asp:Table ID="tbl1" Width="100%" runat="server">
<asp:TableRow>
<asp:TableCell Width="100px">This is a test table Giddy
UP!</asp:TableCell>
</asp:TableRow>
</asp:Table>

if your using a style sheet then do this:

<asp:Table ID="tbl1" Width="100%" runat="server">
<asp:TableRow>
<asp:TableCell Width="100px" CssClass="yourStyles">This is a
test table Giddy UP!</asp:TableCell>
</asp:TableRow>
</asp:Table>
 
V

vpravin

cud it be tht this is more complicated bcuz i am creating/adding the
rows dynamically.?
 
M

Mike

No, because once you set the width it should be set no matter how your
setting the rows. Show all of your HTML code for your table. Let can help
me see what your doing and having issues with.

Though you may be better off using a grid, that renders a HTML table but you
can 'customize' it a little easier then with a asp:table in the HTML. You
may have a syntax error in the HTML and that can break your table's layout.
Show your HTML
 

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,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top