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

nullable dataitem reference handling

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 2
Mario asked on 01 Oct 2009, 03:23 PM
Hi,

i want to give my radGrid's TemplateItem control the following textbinding from my Linq2Sql object which has a user2id propertie foreign key:

Text='<%# DataBinder.Eval(Container.DataItem,"User2.lastname").ToString() %>'

but what can i do to handle the case that the user2id foreign key is null which makes the User2 object null?

is there a chance to handle it in the asp code?

Or do i have to catch the user2id instead of the User2 object and use it in codebehind with the ItemDataBound?

thx, Mario

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 06 Oct 2009, 04:11 PM
Hello Mario,

Just remove the ToString() method call from the binding expression.

I hope this helps.

Regards,
Tsvetoslav
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
Grid
Asked by
Mario
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Share this question
or