Intersoft WebGrid Documentation
How-to: Create FormatConditions in a specific row and cell
See Also Send comments on this topic.

Glossary Item Box

WebGrid provides FormatConditions feature to help you create your own format for the information/data in WebGrid.

In this topic, you will learn how to create FormatConditions in specific row and cell using table Customers from NorthWind database.

To create FormatConditions in a specific row and cell

 Add InitializeLayout server side event:

C# Copy ImageCopy Code
using ISNet.WebUI.WebGrid; 

private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
{    
   //specific row     
   WebGridFormatCondition a = new WebGridFormatCondition();     
   a.ColumnMember = "Country";     
   a.ConditionText = "UK";     
   a.Name = "Format1";     
   a.FormatStyle.ForeColor = Color.Red;     
   a.TargetObject = ISNet.WebUI.WebGrid.TargetObjectType.Row;         

   //specific Cell     
   WebGridFormatCondition b = new WebGridFormatCondition();     
   b.ColumnMember = "City";     
   b.ConditionText = "Madrid";     
   b.Name = "Format2";     
   b.TargetColumnMember = "City";     
   b.FormatStyle.Font.Bold = true;     
   b.TargetObject = ISNet.WebUI.WebGrid.TargetObjectType.Cell;       

   WebGrid1.RootTable.FormatConditions.Add(a);     
   WebGrid1.RootTable.FormatConditions.Add(b);
}     

Please note that if you are using RetrieveStructure, then you need to put the above codes in PrepareDataBinding.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.