Customizing Columns Using ValueLists
This topic demonstrates how to change the display of cell data using the ValueList property.
The ValueList property sets the object that implements the IDictionary interface used for textual substitution. In order to substitute text, a dictionary containing replacement text must be created.
1. To create a ValueList dictionary, add the following code to the Page_Load event:
'Prepare ValueList dictionary
Dim ht As New Hashtable()
ht.Add("1", "Beverages")
ht.Add("2", "Condiments")
ht.Add("3", "Confections")
ht.Add("4", "Dairy Products")
ht.Add("5", "Grains/Cereals")
ht.Add("6", "Meat/Poultry")
ht.Add("7", "Produce")
ht.Add("8", "Seafood")
• C#
//Prepare ValueList dictionary
Hashtable ht = new Hashtable();
ht.Add("1", "Beverages");
ht.Add("2", "Condiments");
ht.Add("3", "Confections");ht.Add("4", "Dairy Products");
ht.Add("5", "Grains/Cereals");
ht.Add("6", "Meat/Poultry");
ht.Add("7", "Produce");
ht.Add("8", "Seafood");
2. Assign the column, CategoryID in this example, that contains the items to be replaced by the items in the ValueList dictionary:
CType(C1GridView1.Columns.ColumnByName("CategoryID"), C1.Web.UI.Controls.C1GridView.C1BoundField).ValueList = ht
• C#
((C1.Web.UI.Controls.C1GridView.C1BoundField)C1GridView1.Columns.ColumnByName("CategoryID")).ValueList = ht;
What You've Accomplished
The items in the CategoryID column of the grid are replaced with the items in the ValueList dictionary and appear in the CategoryID column of the C1GridView.
The initial grid without substituted text appears similar to the following:
The grid with the substituted text appears similar to the following:
Sample Project Available
For the complete sample, see the ValueLists sample located on the ComponentOne HelpCentral Sample page.
|