Assign Reference Value From RadComboBox

Thread is closed for posting
2 posts, 0 answers
  1. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 17 Dec 2008 Link to this post

    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


  2. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 18 Dec 2008 Link to this post

    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.
Back to Top