Brady Kelly
2007-04-28 14:58:46 UTC
I have an HTML table construct where I dynamically create each row (tr) for
a Repeater in the ItemDataBound event. My problem is that with some data
sources, with many columns, my resulting HTML table is too wide. In my
ItemDataBound event I iterate my column definitions and create one
HtmlTableCell for each column, and it's here I would like to set the width
of that column to something narrow than what it defaults to. However,
setting width on the HtmlTableCell has no apparent effect. How should I go
about this?
private void rptUsers_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
HtmlTableRow gridRow = new HtmlTableRow();
TaskType dataRow = e.Item.DataItem as TaskType;
gridRow = taskTypeGrid.BuildHtmlTableRow(dataRow);
((Repeater)sender).Controls.Add(gridRow);
}
public HtmlTableRow BuildHtmlTableRow(EntityBase dataRow)
{
HtmlTableRow gridRow = new HtmlTableRow();
foreach (GridColumnBase col in columns)
{
HtmlTableCell gridCell = new HtmlTableCell();
object dataValue = dataRow[col.BoundField];
gridCell.Width = "50px";
gridCell = col.BuildHtmlTableCell(dataValue);
gridRow.Controls.Add(gridCell);
}
return gridRow;
}
===================================
This list is hosted by DevelopMentor� http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
a Repeater in the ItemDataBound event. My problem is that with some data
sources, with many columns, my resulting HTML table is too wide. In my
ItemDataBound event I iterate my column definitions and create one
HtmlTableCell for each column, and it's here I would like to set the width
of that column to something narrow than what it defaults to. However,
setting width on the HtmlTableCell has no apparent effect. How should I go
about this?
private void rptUsers_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
HtmlTableRow gridRow = new HtmlTableRow();
TaskType dataRow = e.Item.DataItem as TaskType;
gridRow = taskTypeGrid.BuildHtmlTableRow(dataRow);
((Repeater)sender).Controls.Add(gridRow);
}
public HtmlTableRow BuildHtmlTableRow(EntityBase dataRow)
{
HtmlTableRow gridRow = new HtmlTableRow();
foreach (GridColumnBase col in columns)
{
HtmlTableCell gridCell = new HtmlTableCell();
object dataValue = dataRow[col.BoundField];
gridCell.Width = "50px";
gridCell = col.BuildHtmlTableCell(dataValue);
gridRow.Controls.Add(gridCell);
}
return gridRow;
}
===================================
This list is hosted by DevelopMentor� http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com