The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I'm currently building an application that is using a .net TabControl. Each TabPages of the TabControl are being dynamically created durring run-time and can range in number from 1 to 10. Each TabPage contains several Label and TextBox Controls and one Syncfusion GridDataBoundGrid control.
I am able to populate the GridDataBoundGrid control with data when I first create the control. The GridDataBoundGrid is editable to the user, so they are able to change the contents of cells and add or delete rows, so I need to be able to access the data from the control so that I can save it to database.
The problem I am having is accessing the the control (more specifically the data in it) after it's created.
Here is how I am currently accessing the contols on the TabPages:
foreach (TabPage tab in tabControl1.Controls) { foreach (Control ctrl in tab.Controls) { if (control is TextBox) { //Example of accessing my the data in my TextBox controls: string test = control.Text; } else if (ctrl is GridDataBoundGrid) { //Not sure what to do here? } } }
I've tried to typecast the control to a GridDataBoundGrid but that's not working, as in it's not allowing me to access the "Model" subclass to access the data in the cells.
I was trying to access the cells by doing something like this:
foreach (Control ctrl in tab.Controls) { if(ctrl is GridDataBoundGrid) { string myString = (GridDataBoundGrid)control.Model[1, 1].Text } }
This was not working though, as I technically was not able to access the subclasses of GridDataBoundGrid such as "Model".
The solution (or a solution) is to create a new instance of GridDataBoundGrid and assign it the value of the control. This will allow you to access the subclasses of the GridDataBoundGrid class. Example: