R B
R B

Reputation: 423

Table cell alignment not working

I have a table which has a label in the 1st row and a DateTimePicker in the 2nd row as follows:

Table _Table = new Table();

TableRow row1 = new TableRow();
TableRow row2 = new TableRow();
this._Table.Rows.Add(row1);
this._Table.Rows.Add(row2);

TableCell dateCell = new TableCell();
TableCell labelCell = new TableCell();

labelCell.VerticalAlign = VerticalAlign.Bottom;
labelCell.HorizontalAlign = HorizontalAlign.Right;
dateCell.Controls.Add(_DtProposalSigned);
labelCell.Controls.Add(savedLabel);
row1.Cells.Add(labelCell);
row2.Cells.Add(dateCell);  

I am trying to align the label cell so that label is to the right, above the DateTimePicker, but I get the result as follows (Label in the center), though I have aligned it to the right!

enter image description here

Upvotes: 1

Views: 3905

Answers (1)

Suvendu Shekhar Giri
Suvendu Shekhar Giri

Reputation: 1384

I tried the same code and it's working perfect for me. So, here is a check list you may give a try.

  • Make sure that you haven't mentioned width anywhere for 'savedLabel' or Text/innerHTML of savedLabel
  • Make sure that you haven't provided value to the width property of labelCell
  • Make sure that there are no blank spaces after 'Saved !'
  • If you are assigning dynamic value to savedLabel like <div>Saved<div> then make sure that you haven't given it a fixed width like <div style='width:100px;'>Saved</div>
  • You can check all these and other attributes by right clicking on the Saved! and then selecting Inspect Element. Examine the <span></span> element rendered for the label and I am sure, you will be able to find the exact issue and hence the solution.

In case these are not helpful, please let me know.

Upvotes: 4

Related Questions