Bind to complex typed properties

Last post 03-02-2006 5:50 AM by stevenR2. 2 replies.

Sort Posts:

  • Bind to complex typed properties

    03-01-2006, 3:49 AM
    • Member
      90 point Member
    • stevenR2
    • Member since 12-20-2005, 9:09 AM
    • Glasgow, Scotland
    • Posts 18

    I had my bind working fine from my GridView to an object with a property UserID which returned an Int32.

    I decided to modify my object to store a User instead of UserID and so i would refer to the UserID as a property of this complex property.

    However, DataKeyNames doesn't seem to support the syntax change from "UserID" to "User.UserID" - bind also doesn't [seem to].

    "A call to Bind was not well formatted"

    I also seem to have issues accessing the new properties with the same code that works fine when it is a direct property:

    gv.SelectedRow.Cells[0].Text

    However, Eval() does just great.

    For the moment i will just put a proxy property called UserID which actually returns the UserID on the local User property, but it would be nice to just extend my declarative code.

    Is it possible? And if so, anyone know what i am missing.
    If not, why not?

    steven :: http://stevenR2.com
  • Re: Bind to complex typed properties

    03-02-2006, 1:09 AM
    • Star
      14,613 point Star
    • ScottGu
    • Member since 06-05-2002, 8:36 PM
    • Redmond, WA
    • Posts 2,004
    • AspNetTeam
      Moderator

    Hi Steven,

    Unfortunately the Bind() method doesn't support nested properties.  Eval() -- which is read-only -- does though.

    Hope this helps,

    Scott

  • Re: Bind to complex typed properties

    03-02-2006, 5:50 AM
    • Member
      90 point Member
    • stevenR2
    • Member since 12-20-2005, 9:09 AM
    • Glasgow, Scotland
    • Posts 18

    Thanks Scott. Just being inquisitive - but is there a good reason behind this?

    I assume it was tricky to do on a grander scale - i read your post on Url Mapping and assume that it was also more than 20 lines to support nested properties and such :)

     

    steven :: http://stevenR2.com
Page 1 of 1 (3 items)