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

Assign Reference Value From RadComboBox

1 Answer 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brandon
Top achievements
Rank 1
Brandon asked on 18 Dec 2008, 04:45 AM
On an ASP.NET web form I have a RadComboBox and a RadGrid.  Making a selection from the RadComboBox will filter the grid.  The GUI controls are linked to two OpenAccessDataSource controls.  The first one of these points to my Region persistent object and serves the RadComboBox:
    [Telerik.OpenAccess.Persistent(IdentityField = "id")] 
    public class Region 
    { 
        private int id; 
        [Telerik.OpenAccess.FieldAlias("id")] 
        public int Id 
        { 
            get { return id; } 
            set { id = value; } 
        } 
 
        private string regionName; 
        [Telerik.OpenAccess.FieldAlias("regionName")] 
        public string RegionName 
        { 
            get { return regionName; } 
            set { regionName = value; } 
        } 
 
        private DateTime? lastModified; 
        [Telerik.OpenAccess.FieldAlias("lastModified")] 
        public DateTime? LastModified 
        { 
            get { return lastModified; } 
            set { lastModified = value; } 
        } 
    } 
 

The second OpenAccessDataSource points to my Marketer object.  Notice that the marketer object contains a reference to the Region object:
    [Telerik.OpenAccess.Persistent(IdentityField = "id")] 
    public class Marketer 
    { 
        private int id; 
        [Telerik.OpenAccess.FieldAlias("id")] 
        public int Id 
        { 
            get { return id; } 
            set { id = value; } 
        } 
 
        private string marketerName; 
        [Telerik.OpenAccess.FieldAlias("marketerName")] 
        public string MarketerName 
        { 
            get { return marketerName; } 
            set { marketerName = value; } 
        } 
 
        private Region region; 
        [Telerik.OpenAccess.FieldAlias("region")] 
        public Region Region 
        { 
            get { return region; } 
            set { region = value; } 
        } 
 
        private DateTime? lastModified; 
        [Telerik.OpenAccess.FieldAlias("lastModified")] 
        public DateTime? LastModified 
        { 
            get { return lastModified; } 
            set { lastModified = value; } 
        } 
    } 
 

When a user clicks 'Add' on the RadGrid to add a new Marketer, I want to automatically populate the Region field of the new Marketer object with the value that is found in the RadComboBox.  How can I do this?

Thanks


1 Answer, 1 is accepted

Sort by
0
Brandon
Top achievements
Rank 1
answered on 18 Dec 2008, 05:06 PM
I was able to resolve this by setting the grid's AllowAutoInsert to false and tying into the InsertCommand event as mentioned in in Insert/Update/Delete at database level.  I grabbed a new IObjectContext from my persistence layer, created a new Marketer object, used OSQL to query for a new instance of the selected Region and assign it to my new Marketer object, and saved it to the database.
Tags
General Discussions
Asked by
Brandon
Top achievements
Rank 1
Answers by
Brandon
Top achievements
Rank 1
Share this question
or