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
- On WebGrid's PrepareDataBinding event handler, add the following code:
C# Copy 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"); }
- Run the project.