none
LinqDataSource question RRS feed

  • Question

  • i have a question on LinqToSqlDataSource and data controls in ASP.NET.

    for example, i have a DB - (posts *:1 users) in my forum and coresponding DataContext.
    so, when i enumerate and display posts i need to display user's name which posted it.
    when i use ListView control and LinqToSqlDataSource (of posts) with Update, Insert and Delete options,
    in ItemTemplate i bind properties of controls (for example Label's Text).
    with that binding through, for example 'Eval("user.user_login")', i can access to user entity,
    which is associated with currently displaying post.

    and here's question:
    i can access that entity only when i use ListView control, other data controls in this case (for example FormView)
    doesn't see this post's property, post.user is null, and i have to manually in code edit Text property of Label
    by setting OnDataBinding event handler. Are there other solutions, and why it works only with ListView control?

    please mail me, if you know the answer to xeonix@i.ua, thanks!
    Friday, July 4, 2008 11:28 AM

Answers

  • there is a problem:
    EnableUpdate turned on everywhere, but it's not working!
    there is a solution - specify "Select" property of LinqToSqlDataSource with following:
    "new (id, ..., user)", but in this case you can't enable options EnableUpdate, EnableDelete and so on.
    ...and type of each selected element will no more be of "post".

    so, now i'm usng ListView control everywhere, where i need to drill int the properties.
    Monday, July 14, 2008 8:51 AM

All replies

  • I am splitting the thread and moving your question to the LINQ to SQL forum to give it more chances. Also, this is more of an ASP.NET question, so I will raise it to some people in the ASP.NET team.

     

    Thanks,

    Diego

     

    Friday, July 4, 2008 7:08 PM
  •  

    Try setting EnableUpdate=true on your LinqDataSource. This will enable deferred queries which will allow you to drill into the properties. I'm guess that on the page with the ListView you have this enabled but you do not on the other pages.

     

    Scott Hunter

    ASP.NET

    Monday, July 7, 2008 4:44 PM
  • there is a problem:
    EnableUpdate turned on everywhere, but it's not working!
    there is a solution - specify "Select" property of LinqToSqlDataSource with following:
    "new (id, ..., user)", but in this case you can't enable options EnableUpdate, EnableDelete and so on.
    ...and type of each selected element will no more be of "post".

    so, now i'm usng ListView control everywhere, where i need to drill int the properties.
    Monday, July 14, 2008 8:51 AM