JonW
JonW

Reputation: 55

ASP.NET Table Cells Formatting

I am using an asp:Table to keep objects on my page in the correct spot, relative to each other. However, for this page, I need to use a table that has different rows, with a different number of cells, but still be sized/formatted correctly.

I.E

I have one table, with two rows - row 0 has two cells, 00 and 01, and row 1 has one cell, 10.

Currently, the way this gets formatted is as follows:

[Row 0 - [Cell 00] [Cell 01]]

[Row 1 - [Cell 10] -----------]

However, what I want is this:

[Row 0 - [Cell 00] [Cell 01]]

[Row 1 - [----- Cell 10 -----]]

Basically, the default formatting is to keep the columns aligned, but I want the total width of the table to stay the same, and stretch the cells to fit.

I tried to set the width of the cells in row 0 to 50%, and the width of the cell in row 1 to 100%, but that still results in my first example from above.

Upvotes: 0

Views: 224

Answers (1)

Always_a_learner
Always_a_learner

Reputation: 1304

Try columnspan for merging two cell like as below:

<asp:table runat="server" xmlns:asp="#unknown">
 <asp:tablerow>
   <asp:tablecell columnspan="2">

     Merge cell : display Header here
   </asp:tablecell>
 </asp:tablerow>
 <asp:tablerow>
  <asp:tablecell>Cell1</asp:tablecell>
  <asp:tablecell>Cell2</asp:tablecell>
 </asp:tablerow>
</asp:table>

Upvotes: 1

Related Questions