Void dGrid_BeforePerformDataSelect(object sender, EventArgs e)ĪSPxGridView grid=sender as ASPxGridView MasterGrid.DataSource = dh.getDataTable("select * from categories") create detail grid and add it to the detail tamplate Protected void Page_Load(object sender, EventArgs e)
#DEVEXPRESS GRIDVIEW MVC CODE#
Creating the DetailGridTemplateĪt the next code segment, a DetialGridTemplate instance is created and assigned to the mastergrid detial row template in one step.Note, that the detail grid passed as a parameter to the constructor. = true Īs you see the above code creates the master and detail grids and register the BeforePerformDataSelect handler for the detail grid two allow binding the detail grid with a datasource at runtime. Protected void Page_Load( object sender, EventArgs e)ĪSPxGridView MasterGrid = new ASPxGridView() ĭGrid.BeforePerformDataSelect += dGrid_BeforePerformDataSelect Public partial class MasterDetailPage : .Page Using MasterDetailTemplateRuntim.AppCode
![devexpress gridview mvc devexpress gridview mvc](https://www.devexpress.com/products/net/controls/asp/mvc/media/aspnet-mvc-extensions.png)
The second method (getDataTable) used to get a datatable and it takes a query as string parameter to be executed aginst the database. The DataHelper Class contains two methods the first method (GetConnection) used to get database connection for the database MasterDetailDB on the local server. I created a simple DataHelper Class to retrieve data from the database i will not be focused on the practices to get data from database but the way to create and bind the data to detail template grid. net framework 4.5 with examples written in C# ,and the devexpress version I used is Version=15.2.4.0. I created database using SQL server 2012 and the application is written for. I created also a simple database that contains a master table (Categories) and another detail table (Products) and a record in (Products) table refere to a record in (Categories) table as the following image shows. I will create an empty Visual Studio ASP.NET Web Application. I will be using ASP.NET suite of controls, more specifically Web Forms Creating the project
#DEVEXPRESS GRIDVIEW MVC HOW TO#
In this article I will show you an example for aspxgridview (which is a popular control used in data driven applications) and how to bind it dynamically at runtime . IntroductionĪs a web developer I may use DevExpress controls in many of web applications. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. This article appears in the Third Party Products and Tools section.