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

Need to use different datasource for edit usercontrol

5 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antony
Top achievements
Rank 1
Antony asked on 15 Oct 2008, 04:11 PM
HI,

I have a grid that represents rows in a table.
The table contains 10 fields of information, of which the user 99% of the time will only want to see 3 fields.
I have created a datasource containing these 3 fields and have bound this to the grid.

On the odd occasion that the user needs to edit a row in the grid, the grid displays a custom web usercontrol that contains all 10 fields of information.

What is the best way to load the data into the usercontrol?

I would like to somehow specify 2 datasources for the grid, 1 to be used for the grid display, ie containing just the 3 fields and  another to be used when editing a row and displaying the usercontrol, this datasource would contain all the 10 fields of information for the selected row in the grid and should be loaded on demand just before displaying the edit usercontrol.

If all of this could be somehow hooked up to the DataItem property which I have created in my Usercontrol that would be great.

Hope this makes sense, any suggestions welcomed.
Antony

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Oct 2008, 08:11 AM
Hi Antony,

Basically, you can include all columns in the datasource, and toggle off the display for the unneeded columns by using the display property. In this way, the data will not be visible, but will be accessible for editing.
I hope this suggestion gets you started properly.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Antony
Top achievements
Rank 1
answered on 20 Oct 2008, 08:31 AM
Hi Yavor,

Yes I did realize that I could include all the columns in a single datasource and hide the ones I don't want to display, the point is that I don't want to have the overhead of selecting and transferring a dataset containing 10 columns of data for each row when I only need 3 columns until the user on the off chance decides to edit one of the rows in the grid and even then I only need all 10 columns of data for the one selected row being edited.

Thanks
Antony
0
Yavor
Telerik team
answered on 22 Oct 2008, 07:30 AM
Hello Antony,

In this case, you can use a separate datasource for the user control. For example, from the code-behind, you can set the values for the textboxes, by querying the database based on the presently edited row in the grid. Then, once the user control raises a command, you will need to manually extract the values entered by the user.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Antony
Top achievements
Rank 1
answered on 22 Oct 2008, 08:04 AM
Hi Yavor,

Thanks for your response it is what I am looking for, is there any chance you could send me an example of how to hook this all up?


Many thanks
Antony
0
Yavor
Telerik team
answered on 22 Oct 2008, 08:43 AM
Hello Antony,

Attached to this message, is a small application, which handles the desired functionality.
I hope it helps.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Antony
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Antony
Top achievements
Rank 1
Share this question
or