Here's what I'm running:
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.
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?
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.
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?
Note: jQuery does not cause the issue as it was occurring before jQuery was apart of the project.
I've also posted this same question on http://stackoverflow.com/questions/1499598/programmtically-adding-two-infragistics-ultrawebgrids-renders-only-one-grid-with
Ok, no problem.
Finally I resolve the problem with
grid.DisplayLayout.OptimizeCSSClassNamesOutput = Infragistics.WebUI.Shared.DefaultableBoolean.False
and Cascading Style Sheets: http://forums.infragistics.com/forums/p/3598/38850.aspx
@breakingBad - My apologies, I answered the wrong question. Sorry 'bout that. However, I did some tests though and adding two grids programmatically retains style. The problem I discovered is with our proprietary framework for building the UltraWebGrids. So I need to see what's up in our own framework but just adding two grids and binging them programmatically works fine.
Here's the sample code:
Markup:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestGrids._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> </div> </form></body></html>
Code-behind:
using System;using System.Data;using Infragistics.WebUI.UltraWebGrid;using System.Web.UI.WebControls;namespace TestGrids{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { CreateGrids(); BindData(); } private void CreateGrids() { string presetFile = Server.MapPath("~/CviAEFieldGridTheme.xml"); grid1 = new UltraWebGrid(); grid1.ID = "grid1"; grid1.LoadPreset(presetFile, false); grid1.DisplayLayout.AutoGenerateColumns = true; form1.Controls.Add(grid1); Literal space = new Literal(); space.Text = "<br /><br /><br />"; form1.Controls.Add(space); grid2 = new UltraWebGrid(); grid2.ID = "grid2"; grid2.LoadPreset(presetFile, false); grid2.DisplayLayout.AutoGenerateColumns = true; form1.Controls.Add(grid2); } private void BindData() { DataTable dataTable = new DataTable("Customers"); DataColumn colWork = new DataColumn("CustomerID", Type.GetType("System.Int32")); dataTable.Columns.Add(colWork); DataColumn[] keys = { colWork }; dataTable.PrimaryKey = keys; colWork = new DataColumn("CustomerName", Type.GetType("System.String")); colWork.MaxLength = 50; dataTable.Columns.Add(colWork); colWork = new DataColumn("LastOrderDate", Type.GetType("System.DateTime")); dataTable.Columns.Add(colWork); DataRow row = dataTable.NewRow(); row["CustomerID"] = 1; row["CustomerName"] = "John's Widgets"; row["LastOrderDate"] = DateTime.Now; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["CustomerID"] = 2; row["CustomerName"] = "Fred's Thingamagigs"; row["LastOrderDate"] = DateTime.Now.AddDays(-101); dataTable.Rows.Add(row); grid1.DataSource = dataTable; grid1.DataBind(); grid2.DataSource = dataTable; grid2.DataBind(); } private UltraWebGrid grid1; private UltraWebGrid grid2; }}
Hi,
yes please, I don't understand how you solve the style problem with the client-side hashtable.
Do you find the cause of the problem?
Thanks!!
@breakingBad - What I did was build a client-side hashtable on the server which contains the names of all the column keys and on the client-side, I simply reference columns by key instead of index. It works perfectly.
Let me know if you need a code sample to do this.
Hi!,
I have the same problem, do you find the solution?
I try with the 2009 components and nothing solve.
Thanks!