开发者

Databinding multiple tables linq query to gridview?

开发者 https://www.devze.com 2023-01-02 09:42 出处:网络
My question is how can I display a linq query in a gridview that has data from multiple tables AN开发者_StackOverflow中文版D allow the user to edit some of the fields or delete the data from a single

My question is how can I display a linq query in a gridview that has data from multiple tables AN开发者_StackOverflow中文版D allow the user to edit some of the fields or delete the data from a single table?

I'd like to do this with either a linqdatasource or a linq query. I'm aware I can set the e.Result to the query on the selecting event. I've also been able to build a custom databound control for displaying the linq relations (parent.child).

However, I'm not sure how I can make this work with delete? I'm thinking I may need to handle the delete event with custom code.


Okay, I can use a template field to display some of the fields I need:

      <asp:TemplateField HeaderText="header">
            <ItemTemplate>
            <%#Eval("object.subobject") %>
            </ItemTemplate>
      </asp:TemplateField>

Now, I remember I had to create custom bound field types so that I could edit these but in this case that is not required.

So, in this case I think I'm good to go when using the linqdatasource and the subobjects. But, what if I wanted to add delete for a query that returned an anonymous type?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号