
Nick Jones
Top achievements
Rank 1
Nick Jones
asked on 24 Mar 2011, 04:32 PM
Hi
Linking a dropdownlist to a datatable seems simple enough:
But I want to display the persons full name and the display member. Logically I'd write something like this:
But that obviously doesn't work. Anyone know how to run through the dropdown list collection and add the surname?
Linking a dropdownlist to a datatable seems simple enough:
cbEName.DataSource = Main.DataSet.Employee
cbEName.DisplayMember =
"FName"
cbEName.ValueMember =
"id"
But I want to display the persons full name and the display member. Logically I'd write something like this:
cbEName.DataSource = Main.DataSet.Employee
cbEName.DisplayMember =
"FName"
&
" "
&
"LName"
cbEName.ValueMember =
"id"
But that obviously doesn't work. Anyone know how to run through the dropdown list collection and add the surname?
6 Answers, 1 is accepted
0

Nick Jones
Top achievements
Rank 1
answered on 25 Mar 2011, 10:54 AM
In case anyone is interested this is how I solved it.
For
Each
record
As
DataSet.EmployeeRow
In
Main.DataSet.Employee
For
Each
emp
As
RadListDataItem
In
cbEName.Items
If
record.id = emp.Value
Then
emp.Text = emp.Text.Trim &
" "
& record.LName
End
If
Next
Next
0
Hello Nick,
I hoper this will be useful. If you need further assistance, I would be glad to provide it. Best wishes,
Ivan Petrov
the Telerik team
Thank you for writing and for sharing your solution.
You can also subscribe to the VisualListItemFormatting event of the RadDropDownList and format the text of the menu items. There is a small drawback as the text in the RadDropDownList will display only the display member not the formatted text of the menu item. The plus however is that you will avoid the two nested foreach loops.
void
radDropDownList1_VisualListItemFormatting(
object
sender, VisualItemFormattingEventArgs args)
{
DataRowView row = args.VisualItem.Data.DataBoundItem
as
DataRowView;
args.VisualItem.Text = row[
"FirstName"
] +
" "
+ row[
"LastName"
];
}
I hoper this will be useful. If you need further assistance, I would be glad to provide it. Best wishes,
Ivan Petrov
the Telerik team
0

PROGRA
Top achievements
Rank 1
answered on 19 Jul 2013, 12:19 AM
ADD TO PROPERTY ValueMember
0
Hello Cervantes,
Thank you for writing.
Unfortunately, half of a sentence is not enough for me what do you mean, hence I am not able to give you any kind of meaningful answer. Can you please, explain what your question is or what you want to achieve in more details. Any pictures or sketches that illustrate your requirement would also be very useful.
Looking forward to your reply.
Regards,
Ivan Petrov
Telerik
Thank you for writing.
Unfortunately, half of a sentence is not enough for me what do you mean, hence I am not able to give you any kind of meaningful answer. Can you please, explain what your question is or what you want to achieve in more details. Any pictures or sketches that illustrate your requirement would also be very useful.
Looking forward to your reply.
Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Alejandro
Top achievements
Rank 1
answered on 02 Aug 2017, 03:24 PM
Hi.
I Solved adding a auto generate prop inside my class like it follows:
public
string
FullName
{
get
{
return
FName +
" "
+ LName ;
}
}
And then you can call it just like this:
cbEName.DataSource = Main.DataSet.Employee;
cbEName.DisplayMember = "FullName"
cbEName.ValueMember = "id";
0
Hello Alejandro,
Thank you for writing.
Indeed, creating a property that combines multiple fields is the appropriate approach for displaying more than one field. It is just necessary to set that field as DisplayMember.
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Thank you for writing.
Indeed, creating a property that combines multiple fields is the appropriate approach for displaying more than one field. It is just necessary to set that field as DisplayMember.
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.