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

RadGrid and ObjectDataSource

2 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Tabatadze
Top achievements
Rank 1
David Tabatadze asked on 13 Apr 2011, 03:24 PM

Hello.

I use RadGrid and ObjectDataSource (ods) to fill the grid with data.

I used to make insert, update and delete from code behind (using RadGrid events: UpdateCommand, DeleteCommand , etc) - so, i used to create my objects using FindControl(string id) and then manipulate with them.

Now, I decide to do this using ods, but i cannot work it out while i have nested objects.

(in case of single object it works fine - i mean if i Insert, Update or Delete only Person class - see below)

Here is my example:

class User{                                 class Person{ 
  int ID                                       int ID; 
  int PersonID;                                string FirstName; 
  string UserName;                             string LastName; 
}                                           }

My ods methods are:

              SelectMethod: iList<User> GetUsers();
InsertMethod, UpdateMethod: void SaveUser(User u);
              DeleteMethod: void DeleteUser(User u);

In my EditFormTemplate i bind these like this (binding works fine):

<telerik:RadTextBox ID="txtUserName" runat="server"  Text='<%# Bind("UserName") %>'/>
<telerik:RadTextBox ID="txtFirstName" runat="server"  
 Text= '<%# DataBinder.Eval(Container.DataItem, "Person.FirstName") %>' /> 
<telerik:RadTextBox ID="txtLastName" runat="server"
 Text= '<%# DataBinder.Eval(Container.DataItem, "Person.LastName") %>' />

So, when i am trying to update user object, updates only UserName, update does not cause to FirstName and LastName (User.Person properties). I guess ods cannot recognize them at all...

Is there any solution for this?

Or is there any alternative way to act situations lake this?

P.S. the same problem is when i use LinqDataSource

thanks.

2 Answers, 1 is accepted

Sort by
0
David Tabatadze
Top achievements
Rank 1
answered on 15 Apr 2011, 12:59 PM

Hello, still no replies...

Plz, response me

0
Mira
Telerik team
answered on 18 Apr 2011, 03:40 PM
Hello David,

Generally, Bind is used for two-way databinding and Eval - for one-way. The problem is that Bind cannot be used for nested objects.
You can either update the data manually, or use some of the workarounds listed below:

I hope this helps.

All the best,
Mira
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
David Tabatadze
Top achievements
Rank 1
Answers by
David Tabatadze
Top achievements
Rank 1
Mira
Telerik team
Share this question
or