We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Edit all rows of dynamic grid

Hi I have generated the grid dynamically, where all the data, including column headers, is pulled from datasets. After which, i would like to edit all the rows at the same time from this dynamically created grid. May i know if this is being supported? Any assistance much appreciated. I am using C# on ASP.NET 2.0).

11 Replies

AD Administrator Syncfusion Team September 7, 2005 11:13 AM UTC

Hi This can be accomplished using templates and is demonstrated in the EditAllRows sample. Essential Studio 3.3 ships with Whidbey (beta 2) samples for Essential Grid for ASP.NET. Take a look at the sample located in the \Syncfusion\Essential Studio\3.3.0.0\Web\Grid.Grouping.Web\Samples\2.0\Editing\EditAllRows folder or via the Sample Browser by choosing Visual Studio 2.0. You can download Essential Studio 3.3 from : www.syncfusion.com/latestversion.aspx Regards Arun


AD Administrator Syncfusion Team September 8, 2005 01:18 AM UTC

Hi, Thanks for your prompt reply. However what i wish to do is different from the sample in a way such that the columns which i pull from the dataset varies all the time. Is it still possible to use templates? >Hi > >This can be accomplished using templates and is demonstrated in the EditAllRows sample. Essential Studio 3.3 ships with Whidbey (beta 2) samples for Essential Grid for ASP.NET. Take a look at the sample located in the \Syncfusion\Essential Studio\3.3.0.0\Web\Grid.Grouping.Web\Samples\2.0\Editing\EditAllRows folder or via the Sample Browser by choosing Visual Studio 2.0. > >You can download Essential Studio 3.3 from : >here > >Regards >Arun >


AD Administrator Syncfusion Team September 8, 2005 02:29 AM UTC

Correct me if i''m wrong. To be able to edit all the rows using templates, i will have to define the the columns header in the code first nad it is not possible to do so if the columns header keep changing and when the number of columns varies.


AD Administrator Syncfusion Team September 8, 2005 03:11 PM UTC

Yes, you are correct, the templates can only be defined in the designer. A good and easy workaround for this is to use a dummy grid in the form with a dummy column descriptor initialized with the template you will be using in the grid whose columns will be dynamically generated. You can then reuse that template from the dummy grid in the dynamically initialized grid. A simple retrieval and assignment like this will do: ITemplate desiredTemplate = this.dummyGrid.TableDescriptor.Columns[0].ItemTemplate; this.DynamicGrid.TableDescriptor.Columns[2].ItemTemplate = desiredTemplate; And then hide the dummy grid, of course. You can in fact reuse a single template across different columns - since the logic that fetches the data will be based on the column in which the template gets used. Let us know if you need more help. Regards, Praveen Ramesh


AD Administrator Syncfusion Team September 9, 2005 02:29 AM UTC

Do you mean by having a dummy grid with all the possible columns defined by templates, i can retrieve the required template for a column and put into the actual grid to be displayed? Does that means that if i have thousands of columns, my dummy grid will be huge? Thanks


AD Administrator Syncfusion Team September 9, 2005 03:00 AM UTC

Also, in this case do i have to change the code whenever there is an addition of a new column that i wish to display on the grid?


AD Administrator Syncfusion Team September 9, 2005 06:28 PM UTC

Hi Quek Here is a modified version of the EditAllRows sample where you can dynamically change the number of columns. You can unzip this sample to the \Program Files\Syncfusion\Essential Studio\3.3.0.0\Web\Grid.Grouping.Web\Samples\1.1\Editing directory and create virtual directories pointing to the appropriate cs\vb sample directory and then try building and running this sample. Enter the number of columns and click on the Update Grid Button to dynamically change the number of columns. Do not hesitate to contact us if you have any further questions. Regards Arun


AD Administrator Syncfusion Team September 9, 2005 06:34 PM UTC

Hi Quek Try this link instead to download the sample. Sorry for the inconvenience. Regards Arun


AD Administrator Syncfusion Team September 13, 2005 07:01 PM UTC

Hi Quek, This sample demonstrates how to connect to different tables dynamically and also use different types of templates for different fields based on the field type. When the user adds a new column, the grid’s data binding has to be basically reset (as if it’s going to bind to a new table), then the new column can also be edited. This is not illustrated, if you need help with this do not hesitate to contact us. Regards Arun


AD Administrator Syncfusion Team September 14, 2005 01:31 PM UTC

Hi Arun, Are you saying that if i have a new column in my database i have to personally reset the binding? Or can it all be automated?


AD Administrator Syncfusion Team September 14, 2005 02:23 PM UTC

Yes, when a new column gets added to the database, the cleanest way is to rebind the grid to the datasource. In the attached sample, you would implement the logic like this: // Let''s say this is the event that will cause one or more columns to be added to the currently bound table. // Let''s say this is the event that will cause one or more columns to be added to the currently bound table. // Let''s say this is the event where a new column gets added to the table: private void Some_Event(object sender, System.EventArgs e) { // Add new columns to the table. // ... (Code for this goes here) // Then call this method: to refresh the grid''s databinding // Code for this method is in the sample. this.UpdateGridsDataSource(); } Regards, Praveen

Loader.
Live Chat Icon For mobile
Up arrow icon