Creating a Custom Property that you can bind with

Thread is closed for posting
4 posts, 0 answers
  1. Steve
    Steve avatar
    1886 posts
    Member since:
    Dec 2008

    Posted 25 Jan 2010 Link to this post

    I've got a firstname column, and a lastname column...I want to create a property called FullName which returns a combination of the two.

    Whats the syntax to create that in my class such that I can set my RadComboBox DataTextField to be FullName (right now it doesnt even see it)

    Or is that even possible
  2. Jeremy Mann
    Jeremy Mann avatar
    23 posts
    Member since:
    Jul 2009

    Posted 25 Jan 2010 Link to this post

    Steve, I'm doing things like this adding just a standard Get property on my Persistent Entity Objects.

    public string FullName{ 
          return string.Format("{0} {1}"this.FirstName, this.LastName); 

    Just make sure you dont put a FieldAlias on the property.  Keeping in mind this is for Eval as Bind is two-way and needs a set method.  I suppose you could put a set and split the string based on the space, but I'm guessing Eval is all you need.
  3. Steve
    Steve avatar
    1886 posts
    Member since:
    Dec 2008

    Posted 25 Jan 2010 Link to this post

    Hmmm...perhaps I'm doing it wrong then...because that's exactly what I have

    Server Error in '/' Application.

    Invalid column name 'FullName'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'FullName'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SQLException: Invalid column name 'FullName'.]
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery() +495
       OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery() +91
       OpenAccessRuntime.Relational.fetch.FetchResultImp.execute() +90

  4. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 26 Jan 2010 Link to this post

    Hello Steve,

    You could use the approach that Jeremy Mann proposed to you in order to achieve this goal:
    1. Add the FullName property inside the persistent class

    public string FullName
     get { return String.Format("{0} {1}", this.FirstName, this.LastName); }

    2. Add an OpenAccessDataSource control inside the ASP.NET page and bind it to the persistent class:
    - Configure data source;
    - Select the proper persistent class;
    3. Add a RadComboBox control and bind it to the OpenAccessDataSource

    <telerik:RadComboBox ID="RadComboBox1" runat="server" DataTextField="FullName" DataValueField="PersistentClassId"

    You could use the attached solution which we provided to you.
    Hope that helps.

    Sincerely yours,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top