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

Custom Insert and Edit Forms

7 Answers 344 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 22 Sep 2011, 02:47 PM
Hi,

I have a radgrid bound to an entitydatasource control, I want to use user controls for the insert and edit forms, what is the best way to do this?

Is it possible to alter the auto generated edit forms or are user controls the only way to go?

Regards

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Sep 2011, 02:45 PM
Hello Albert,

You can create customize the Edit form with Form template or by using User control.
Take a look into the following demo which explains the same.
Grid / Form Template Edit Form.
Grid / User Control Edit Form.

Thanks,
Shinu.
0
Albert
Top achievements
Rank 1
answered on 13 Oct 2011, 12:58 AM
Hi,

The examples in your previous reply are for SQL Datasources (and datatables), I really need an example using the entity framework datasources.

I am beginning to think that I am better of using Microsoft FormView controls to update and edit records rather than trying to use Web User Controls in a Telerik grid, there seems to be a lot less code, am I wrong?

Thank you in advance for your time.

Regards
0
Iana Tsolova
Telerik team
answered on 17 Oct 2011, 10:07 AM
Hello Albert ,

If your grid works with SqlDataSource, there is no reason for it not to work with EntityDataSource in case it is properly configured. Can you share the grid and the EntityDataSource controls declaration as well as any related code, and this for the user control so we can perform further check on it?

Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Albert
Top achievements
Rank 1
answered on 17 Oct 2011, 03:41 PM
Hi Iana (nice name!),

Thank you for your reply. I am trying to convert your own Telerik example that uses SQL datasources to Entity Framework datasources. Here is the link.

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

Please could you send me an altered version amended for Entity framework, I have yet to be convinced that the code needed to get this to work (if it does work!) is easier than using Microsoft FormView controls. I am hoping that you can prove me wrong. 

Regards
0
Accepted
Iana Tsolova
Telerik team
answered on 18 Oct 2011, 03:52 PM
Hello Albert ,

This demo uses manual data source operations and it cannot work with automatic DataSource operations as is because the user control does not implement the IBindableTemplate interface. You can see how this should be done in this blog post.
Otherwise you will have to implement the CRUD operations manually or give try of the FormTemplate edit form type

Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Albert
Top achievements
Rank 1
answered on 28 Oct 2011, 01:02 PM
Hi Iana,

I have managed to get the template form to work with the entity datasource so I will be marking your last response as the answer.

However, I noticed that the RadGrid does not have "inserting" or "updating" events, how can I access and change values or set default values before they are committed to the database?

Regards
0
Accepted
Kevin
Top achievements
Rank 2
answered on 28 Oct 2011, 01:33 PM
Hello Albert,

You can use the EntityDataSource's Inserting and Updating events and access the entry that will be inserted/updated and make any changes to it there. It would look something like so:

protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        // get car that will be inserted
        Car car = (Car)e.Entity;
        // set default value
        car.ProductionDate = DateTime.Now;
    }

I hope that helps.
Tags
Grid
Asked by
Albert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Albert
Top achievements
Rank 1
Iana Tsolova
Telerik team
Kevin
Top achievements
Rank 2
Share this question
or