FYI, this is a copy paste from my post on the Infragistics forums, see http://community.infragistics.com/forums/t/32458.aspx
No answer from them yet so I thought I'd drop this one down on the stackoverflow peeps.
Here's what I'm running:
- ASP.NET 2.0 AJAX Extensions 1.0 web application
- Infragistics2.WebUI.UltraWebGrid.v7.3, Version=7.3.20073.1041
- Using the UltraWebGridTheme.xml for grid styling.
- Using a master page.
Now as I mentioned in the title, this only occurs when adding UltraWebGrids programmatically and only if there is more than one grid. If I just put one or more UltraWebGrids in a *.aspx, all the grids render with the same style.
Please note that I tried the grid.DisplayLayout.OptimizeCssOutputNames = Infragistics false
but this does not resolve the issue. I tried this more out of desperation.
Here's what's happening in the code:
- We have a Default.aspx whose Page_Load method calls a proprietary control factory class that returns an UltraWebGrid.
- The UltraWebGrid returned from the control factory class does not have any UltraWebGrid properties set explicitly.
- In the FieldBase class Grid.LoadPreset(styleFile, false) is called where styleFile is the filename (not using the stream overload). I know this works because the last grid always gets style.
For Jan, here's some of the class from the framework that I took over that uses the created UltraWebGrid:
public class FieldGrid : FieldBase
{
#region Public Constructors
public FieldGrid()
{
}
#endregion
#region Public Methods
/// <summary>
/// Addsa column to a grid.
/// </summary>
/// <param name="column">A grid column.</param>
public void AddColumn(UltraGridColumn column)
{
if (null != grid)
{
grid.Columns.Add(column);
}
}
public override void AttachControls(Hashtable ctrls)
{
base.AttachControls(ctrls);
...
grid = (UltraWebGrid)ctrls["udgGrid"];
...
}
public override void SetProperty(string name, string value)
{
switch (name.ToLower())
{
case "allowaddnew":
AddNewRowVisible = Convert.ToBoolean(value);
break;
case "updaterowrequired":
if (Convert.ToBoolean(value))
{
grid.UpdateRow += UpdateGridRow;
}
break;
...
default:
base.SetProperty(name, value);
break;
}
}
#endregion
#region Protected Methods
protected void AttachEvents()
{
grid.InitializeRow += InitializeRow;
grid.ItemCommand += GridItemCommand;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
...
grid.ID = ID + "_" + grid.ID;
...
AttachEvents();
...
}
protected void InitializeRow(object source, RowEventArgs e)
{
DataRowView drv = (DataRowView)e.Data;
...
}
...
}
I really want to avoid having to do a hack like copying all style from the one styled grid on the client-side. One because I try to avoid hacks and two, copying all the style could be an adventure as it's not just a table. The actual grid markup is horrendous, a span, then a table with another table inside...
So my question is, is this an Infragistics issue when adding more than one UltraWebGrid programmatically, or is there some flag that needs to be set if more than one grid is added programmatically?
Also, we'll be upgrading to the 2009 components in the next couple of months. Does the 2009 components' webgrid have this issue as well?