This is a migrated thread and some comments may be shown as answers.

[Solved] RadGrid insert/update/delete with dynamic columns

1 Answer 202 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syazwan Ahmad
Top achievements
Rank 1
Syazwan Ahmad asked on 01 Aug 2009, 03:20 AM
Hello.

Telerik version: 2009.2.701.20
Database: MySQL 5

I have a page with 2 controls, RadComboBox and RadGrid.

RadComboBox lists the tables I have in my database, databound onload. RadGrid then loads the table content via ajax.

Now problem comes when I want the Insert/Update/Delete functionality. So far all examples and demos I have found requires the use of declarative approach. I cannot do this when  I do not know exactly how many columns there will be, and what the column names are.

Although they share the same primary key, they may have additional columns.

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Aug 2009, 07:05 AM
Hi Syazwan,

As far as I understood Select and Delete functionality won't be a problem for you. But Insert and Update operation requires the column names to be specified in their respective Insert/Update Command . So one suggestion would to set the DataSource for the Grid in the SelectedIndexChanged event of the RadCombobox and then loop through the column collection and then access the column names. Once you get the column names you may generate the Insert/Update command query dynamically.

Thanks
Shinu.
Tags
Grid
Asked by
Syazwan Ahmad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or