Infragistics: NetAdvantage for .NET 2007 Vol 1 CLR 2 - Cheatsheet: UltraWebGrid

This week I had the pleasure of using Infragistics, and I must say that it was a rather great treat! During the course of adding Ultra Web Grid's to a few  pages I thought that creating a Cheatsheet would be great due to my lack of experience with this product. So below you will fined code that just outlines the basics of the Ultra Web Grid along with implementing custom paging using Alpha characters.


Infragistics Gotchas: 

Setting properties in code and in property tool bar, causes unexplained issues.

Example of this:   PageSize in code and then setting something different in property toolbar, unexplained issue.


Cheatsheet Code:

using Infragistics.WebUI.UltraWebGrid;

using Infragistics.WebUI.Shared;


protected void UltraWebGrid1_InitializeLayout(object sender, LayoutEventArgs e)


//adding null column to grid


//Grid Column Order - Column Real Name




// Set a column's headers' captions - Column Name

band.Columns[0].Header.Caption = "Column Name 1" //ColumnName1- Actual Column Name

//hides columns from grid

e.Layout.Bands[0].Columns.FromKey("ColumnName2").Hidden = true;

//formatting currency

UltraGridColumn amtMaxPrice = e.Layout.Bands[0].Columns.FromKey("ColumnName3");

amtMaxPrice.Format = "$###,###.00"

//formatting date

UltraGridColumn DateGenerated = e.Layout.Bands[0].Columns.FromKey("DateGenerated");

DateGenerated.Format = "MM-dd-yy"

//Changing column type - Options (CheckBox, DropDown, Button, Hyperlink)

e.Layout.Bands[0].Columns.FromKey("Edit").Type = ColumnType.Button;

e.Layout.Bands[0].Columns.FromKey("Edit").CellButtonDisplay = CellButtonDisplay.Always;

e.Layout.Bands[0].Columns.FromKey("Edit").CellButtonStyle.Font.Name = "Verdana"

e.Layout.Bands[0].Columns.FromKey("Edit").CellButtonStyle.Font.Size = FontUnit.Point(7);

e.Layout.Bands[0].Columns.FromKey("Edit").CellButtonStyle.BackColor = Color.Lavender;            

//Column Type Hyperlink

e.Layout.Bands[0].Columns.FromKey("View Details").Type = ColumnType.HyperLink;

//To include text on button

            protected void UltraWebGrid1_InitializeRow(object sender, RowEventArgs e)


               e.Row.Cells.FromKey("ColumnName2").Text = "Column Name 2"



//To include text and assign URL Value to hyperlink

protected void ulgridCompany_InitializeRow(object sender, RowEventArgs e)


// With the new HyperLink Column Type, we can utilize the existing Cell. If you set

// the targetURL of the cell then a hyperlink will be created.

// To direct the output towards a target location, add the @[target] to the

// targetURL before assigning the protocol

string s;

          // if the page is onsite we (in this sample) do not need to include the protocol

          if (e.Row.Cells.FromKey("BillInvoice").Value.ToString() == "Active")


             e.Row.Cells.FromKey("BillInvoice").Text = "Bill Invoice"

             s = "BillInvoice.aspx?invoiceID=" + e.Row.Cells.FromKey("BillInvoice").Value.ToString();




            e.Row.Cells.FromKey("BillInvoice 2").Text = "Bill Invoice 2"

            s = "BillInvoice.aspx?invoiceID=" + e.Row.Cells.FromKey("BillInvoice").Value.ToString();


e.Row.Cells.FromKey("BillInvoice").TargetURL = "@[newMethod]" + s;


Adding Custom Paging

string[] alphabet = new string[] {




protected void Page_Load(object sender, System.EventArgs e)


//set pager labels

this.UltraWebGrid1.DisplayLayout.Pager.CustomLabels = alphabet;

if (this.IsPostBack == false)



LoadData("ColumnTypeName LIKE 'A%'");


//Ultra grid property settings

this.UltraWebGrid1.DisplayLayout.Pager.AllowCustomPaging = true;

this.UltraWebGrid1.DisplayLayout.Pager.AllowPaging = true;

this.UltraWebGrid1.DisplayLayout.EnableInternalRowsManagement = true;

this.UltraWebGrid1.DisplayLayout.Pager.StyleMode = PagerStyleMode.CustomLabels;

this.UltraWebGrid1.DisplayLayout.Pager.Alignment = PagerAlignment.Center;

this.UltraWebGrid1.DisplayLayout.Pager.PagerAppearance = PagerAppearance.Both;


//Binding Data To Ultra Web Grid

private void LoadData(string filter)


this.Filter = filter;

DBColumn dbType = new DBColumn();

DataTable tbType = dbType.StoredProc(SomeID);



tbType.DefaultView.RowFilter = filter;

this.UltraWebGrid1.DataSource = tbType.DefaultView;


this.UltraWebGrid1.DisplayLayout.Pager.PageCount = 26;



  1. how would you add a last row with radiobuttons or with buttons. I dont need a column but a horizontal ROW and i need to edit data in columns - not rows. anything i can do about it? so far i am thinking i have to add a last row programmatically and do everything "manually". is this true?

  2. You should be able to make these modifications using the properties menu of infragistics. Yes true, better to have full control


Post a Comment