Ahrensberg
Top achievements
Rank 1
Ahrensberg
asked on 07 Sep 2009, 08:28 AM
Hi all,
I use a RadGrid for showing some users. I using my own datasource there among other things contain firstname and lastname. I extract the data into two columns by setting the datafield in these to DataField="FirstName" and DataField="LastName", respectively.
How can show the full name using only one column? Something like DataField="FirstName & ' ' & LastName"?
Best regards,
Kenneth
I use a RadGrid for showing some users. I using my own datasource there among other things contain firstname and lastname. I extract the data into two columns by setting the datafield in these to DataField="FirstName" and DataField="LastName", respectively.
How can show the full name using only one column? Something like DataField="FirstName & ' ' & LastName"?
Best regards,
Kenneth
4 Answers, 1 is accepted
0
Hello Kenneth,
You can achieve this very easily using template column. Please check the last column in the first grid in this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
Regards,
Vlad
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.
You can achieve this very easily using template column. Please check the last column in the first grid in this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
Regards,
Vlad
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.
0
Ahrensberg
Top achievements
Rank 1
answered on 07 Sep 2009, 08:58 AM
Thank you! :o)
0
Ahrensberg
Top achievements
Rank 1
answered on 07 Sep 2009, 11:37 AM
A (small?) problem. How do I then sort by both datafields?
I can sort by SortExpression="FirstName" or SortExpression="LastName", but how can I do something like SortExpression="FirstName,Lastname"?
I can sort by SortExpression="FirstName" or SortExpression="LastName", but how can I do something like SortExpression="FirstName,Lastname"?
0
Hello Ahrensberg,
You can set the SortExpression="FirstName,LastName". Then on SortCommand event handler you can check for this CommandArgument and rebind the grid to such a version of the data that reflects the desired sorting. This help topic shows details on how to achieve this using SQL datasource. Your SortCommand should look look this:
I hope this helps.
Regards,
Martin
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.
You can set the SortExpression="FirstName,LastName". Then on SortCommand event handler you can check for this CommandArgument and rebind the grid to such a version of the data that reflects the desired sorting. This help topic shows details on how to achieve this using SQL datasource. Your SortCommand should look look this:
protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e) |
{ |
if (e.CommandArgument == "FirstName,LastName") |
{ |
//Request a data from the datasource reflecting the needed sorting |
//Rebind the grid |
} |
} |
I hope this helps.
Regards,
Martin
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.