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

Grid Dropdown Edit Column using Object Datasource, WCF and Entity Framework

4 Answers 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kobus Botha
Top achievements
Rank 1
Kobus Botha asked on 08 Oct 2008, 04:00 PM
Hi,

I am trying to add a dropdown column in the edit form of a RadGrid that is bound to an ObjectDatasource and populated by a WCF Service and using the Entity Framework for Data Access.

Sample: Item has a Item Type Foreign Key.

I can display the text of the foreign key in the RadGrid by using the GridTemplateColumn and Eval("{ForeignKeyEntity}.{DisplayValue}"). I can also display the dropdown column in the edit form but as soon as I change the selected item and I update the row I get a script error where the selected value cannot be converted to a EntitySet.

Can someone please help me with a sample of the proper way to edit the Foreign Key items on an entity using a object datasource.

Thank you,

4 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 13 Oct 2008, 01:12 PM
Hello Kobus,

You will find a project attached to this post demonstrating RadGrid with GridDropDownColumn bound via ObjectDataSource.

The data in the ObjectDataSource is very simple. If you click edit, then update and debug the UpdateRecord method you will see all parameters passed to the business classes. This is the place where you can manipulate the data. 

Best regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kobus Botha
Top achievements
Rank 1
answered on 13 Oct 2008, 04:50 PM
Hi,

Thank you for the reply.

I just need to confirm that there is no other way of using the RadGrid, ODS, WCF and EF combination other than exposing the Foreign Key Entities with an equivalent Simple Type using a partial class?

Taking your sample of Order and modify the EmployeeID to a Employee Entity as would be done by the Entity Framework.

    public class Order
    {
        public Order()
        {
        }

        public Order(int OrderID, Employee Employee, string CustomerID)
        {
            this.OrderID = OrderID;
            this.Employee = Employee;
            this.CustomerID = CustomerID;
        }

        public int OrderID
        { get; set; }

        public Employee Employee
        { get; set; }

        public string CustomerID
        { get; set; }
    }

    public class Employee
    {
        public Employee()
        {
        }

        public Employee(int EmployeeID, string LastName)
        {            
            this.EmployeeID = EmployeeID;
            this.LastName = LastName;
        }

        public int EmployeeID
        { get; set; }

        public string LastName
        { get; set; }
    }

Thank you,
Kobus
0
Nikolay Rusev
Telerik team
answered on 16 Oct 2008, 01:59 PM
Hello Kobus,

Yes this is how Order will look after using Entity Framework.
It will be similar if you use Linq to Sql to generate your classes.

Greetings,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Obed
Top achievements
Rank 1
answered on 14 Feb 2011, 08:13 AM
Now it is working..
Tags
Grid
Asked by
Kobus Botha
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Kobus Botha
Top achievements
Rank 1
Obed
Top achievements
Rank 1
Share this question
or