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

Creating a Custom Property that you can bind with

3 Answers 68 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.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 25 Jan 2010, 07:19 PM
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

3 Answers, 1 is accepted

Sort by
0
Jeremy Mann
Top achievements
Rank 1
answered on 25 Jan 2010, 07:24 PM
Steve, I'm doing things like this adding just a standard Get property on my Persistent Entity Objects.

public string FullName{ 
   get
      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.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Jan 2010, 07:28 PM
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


0
Damyan Bogoev
Telerik team
answered on 26 Jan 2010, 06:56 PM
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"
 DataSourceID="OpenAccessDataSource1">
</telerik:RadComboBox>

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.
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Jeremy Mann
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Damyan Bogoev
Telerik team
Share this question
or