This example demonstrates how to add a Grid View control to a page at runtime and conditionally switch its data source.
The example application's Default page contains an ASPxRadioButtonList and three pre-configured data sources (SqlDataSource). A Grid View control is added to the page in code and bound to the data source that you select from the Radio Button List.
The grid's view state is enabled in this example. Because of this, when the grid is added to the page, it restores its columns from the view state. To generate the columns from scratch when the data source has been changed, clear the ASPxGridView.Columns collection before you call the ASPxGridView.DataBind method.
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- Grid View for ASP.NET Web Forms - How to dynamically switch the Grid's data source and recreate columns at runtime
- Grid View for ASP.NET Web Forms - How to create columns and bind the control to different data sources at runtime
- Grid View for ASP.NET Web Forms - How to bind the control created in design mode to different data sources at runtime
(you will be redirected to DevExpress.com to submit your response)
