Intersoft WebGrid Documentation
How-to: Programmatically set WebValueList's DataSource
See Also Send comments on this topic.

Glossary Item Box

You can set WebValueList for WebGrid programmatically.

In this topic, you will learn the basic thing on how to programmatically set WebValueList's DataSource.

To programmatically set WebValueList's DataSource

  1. On WebGrid's PrepareDataBinding event handler, add the following code:

    C# Copy ImageCopy Code
    protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
    {
        if (!IsPostBack)
        {
            WebGrid1.RetrieveStructure();
        }
        WebValueList vlCat = WebGrid1.RootTable.Columns.GetNamedItem("CategoryID").ValueList; 
        vlCat.SetDataSource("ISDataSource1", "Categories", "CategoryName", "CategoryID");
    }
    

  2. Run the project.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.