ComponentOne GridView for ASP.NET WebForms
Task-Based Help / Formatting the Grid's Content / Customizing Column Data using Value Lists
In This Topic
    Customizing Column Data using Value Lists
    In This Topic

    This topic demonstrates how to change the display of cell data using the ValueList property.
    With the ValueList property, you can substitute the actual cell data values of columns like those with ID data with understandable display values.

    In Code

    Add the following code to the Page_Load event to prepare a ValueList dictionary that contains the replacement text:

    To write the code in VB:

    Visual Basic
    Copy Code
    ' 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")

    To write the code in C#:

    C#
    Copy Code
    // 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");

    Assign the column, CategoryID in this example, which contains the items to be replaced by the items in the ValueList dictionary:

    To write the code in Visual Basic:

      
    Visual Basic
    Copy Code

    ' Assign values from the ValueList dictionary to the actual cell data value.
     CType(C1GridView1.Columns.ColumnByName("CategoryID"), C1.Web.Wijmo.Controls.C1GridView.C1BoundField).ValueList = ht Sub

    To write the code in C#:

      
    C#
    Copy Code
    // Assign values from the ValueList dictionary to the
    actual cell data value.

     ((C1.Web.Wijmo.Controls.C1GridView.C1BoundField)C1GridView1.Columns.ColumnByName("CategoryID")).ValueList = ht;

    What You've Accomplished

    When your run the project, 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:

    See Also