Hello,
I'm programmatically creating some columns in the Page_Load event (if not postback). When I create these columns, I'm setting the width, such as:
On the initial page load, everything is fine. However, when an ajax call happens, such as on paging, the columns are still present in the grid, but their width setting is gone (I verified the TD elements have no width when rendered to the browser).
On the demo site is shows a grid persisting column widths across postbacks (or ajax calls). How can I do this with programmatically created columns? Should their properties be saved in viewstate just like when the columns are defined in the markup?
I'm programmatically creating some columns in the Page_Load event (if not postback). When I create these columns, I'm setting the width, such as:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
GridBoundColumn boundColumn =
new
GridBoundColumn();
boundColumn.HeaderStyle.Width =
new
Unit(100, UnitType.Pixel);
boundColumn.ItemStyle.Width =
new
Unit(100, UnitType.Pixel);
boundColumn.ItemStyle.CssClass =
"noWrapEllipsis"
;
rgCool.MasterTableView.Columns.Add(boundColumn);
}
}
On the initial page load, everything is fine. However, when an ajax call happens, such as on paging, the columns are still present in the grid, but their width setting is gone (I verified the TD elements have no width when rendered to the browser).
On the demo site is shows a grid persisting column widths across postbacks (or ajax calls). How can I do this with programmatically created columns? Should their properties be saved in viewstate just like when the columns are defined in the markup?