Tuesday, October 20, 2009

Reading and adding controls dynamically for templated Column in ultrawebgrid.

I have come across performance issue when we add the controls in the initialize row of ulrtrawebgrid. so i have decided to move in to prerender controls.

After moving the controls in to prerender performance got increased.

void uwgProduct_PreRender(object sender, EventArgs e)
{
TemplatedColumn col = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[0].Columns.FromKey("HeaderCheck");
TemplatedColumn colChild = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[1].Columns.FromKey("ChildCheck");
int rowTotalCount = uwgProduct.Rows.Count;
///Header////
for (int rowcount = 0; rowcount <>
{

CellItem objcellITem = (CellItem)col.CellItems[rowcount];
HtmlInputCheckBox htmlCheck = new HtmlInputCheckBox();
htmlCheck.Attributes.Add("onclick", "selectEachParent(event,this.value)");
htmlCheck.Attributes.Add("id", Convert.ToString(objcellITem.Value));
htmlCheck.Value = Convert.ToString(objcellITem.Value);
objcellITem.Controls.Add(htmlCheck);
}
////Header/////

////Child Display////////
int childTotalCount = colChild.CellItems.Count;
for (int childCount = 0; childCount <>
{
CellItem objcellITem = (CellItem)col.CellItems[rowIndex];
CellItem objcellITemChild = (CellItem)colChild.CellItems[childCount];
HtmlInputCheckBox htmlCheckChild = new HtmlInputCheckBox();
htmlCheckChild.Attributes.Add("onclick", "UnselectParent(event,this.value)");
htmlCheckChild.ID = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
htmlCheckChild.Value = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
objcellITemChild.Controls.Add(htmlCheckChild);
}
////End Child Display////////
}