nullable dataitem reference handling

2 posts, 0 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 01 Oct 2009 Link to this post


    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
  2. Tsvetoslav
    Tsvetoslav avatar
    1823 posts

    Posted 06 Oct 2009 Link to this post

    Hello Mario,

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

    I hope this helps.

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top