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

RadGrid with dynamic datasource and batch edit

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lauren
Top achievements
Rank 1
Lauren asked on 09 Jul 2014, 08:21 PM
I've figured out how to create a RadGrid in batch edit mode, and I've figured out how to change the RadGrid's datasource from a DropDownList of table names... but I'm having trouble combining the two.

Once I switch from a hard-coded datasource (a single table) to the dynamic one, I lose the ability to automatically update/insert/delete.  But I can't realistically manually create CRUD operations for the hundreds of tables in my DropDownList.

Is there a way to use the command parameter to control the table?  I tried it like this, but it doesn't work:

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT * FROM @Table">
<SelectParameters>
    <asp:ControlParameter ControlID="DropDownList1" Name="Table" PropertyName="SelectedValue" Type="String" />
</SelectParameters>

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 14 Jul 2014, 03:19 PM
Hello Lauren,

It is not possible to set the table name from a parameter, but you could change the SelectCommand on server-side, depending on the selected value in the DropDownList. You could take a look at the following forum thread for additional information on this matter:
However, please have in mind that Automatic CRUD operations will work only if the DataSource control is set correctly (thus including the Update, Insert and Delete commands). Detailed information on the automatic CRUD operations is available at the following help article:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Lauren
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or