locked
more than one table on datagrid RRS feed

  • Question

  • User109254540 posted

    I hope you can help me with this. I'm using linq with dynamic data. I need that the datagrid of a custom list template show data of two tables. I tried with an extended query but I get an error. How can I do that??

    thanks in advanced

    Tuesday, September 13, 2011 12:53 AM

All replies

  • User1654722353 posted

    Hello,

    You cannot do this directly. But indirectly by applying logic its possible. You need to combine the data of both table in list (generic list of custom type entity).

    Now bind this list to datagrid.

    Refer this: http://msdn.microsoft.com/en-us/library/z883w3dc.aspx

    Tuesday, September 13, 2011 1:01 AM
  • User-330204900 posted

    The only way to do thi sin Dynamic Data with .Nt 4 is to use a view and if you want the data to be updateable then you will need to use some SROCS

    Tuesday, September 13, 2011 5:12 AM
  • User825619085 posted

    Hi,

    you have to join both table in linq and perform your operation, you can get out put in list or array use of extension method(linq query) and result directly bind it to your datagrid.

    Wednesday, September 14, 2011 5:23 AM
  • User-330204900 posted

    Hi jeet.patel this will nto work in a Dynamic Data application as it does no support data shaping.

    Wednesday, September 14, 2011 7:56 AM
  • User-236004499 posted

    Hi,

    I assume you use Dynamic Data 4.0. If you use SQL Server DB then design database diagram, setup proper relationship. then call/connect database to visual studio project (obviously on ".edmx" file) run your project, if you have define proper relationship then you will get more than two joined tables on gridview without writing single line of code.

    There is another way to do the same; if you have certain business logic or complex output to show on gridview then create view using your query and as mentioned above by "sjnaughton" you can call you "View" on ".edmx" or ".dbml" (I am not sure about .dbml provides or not). and You always write your custom saving process for Insert, Update for this view.

    Well as per microsoft's documentaion the latest version 4.0 and  above of "ADO.Net Entity Framework i.e. .edmx" is much powerfull then the LINQ To SQL as "ADO.Net Entity Framework" inludes LINQ as well.

    There are many article to run customise saving/update process.

    Thanks
    Pratik Solanki

    Wednesday, September 14, 2011 8:37 PM
  • User109254540 posted

    Thank you all. I crated a view and now I going to customize insert, update and delete code. I'm new in dynamic data and now  I'm going to look for documentation of how to do it.

    Thursday, September 15, 2011 12:15 AM
  • User109254540 posted

    I've created a view and I tried to update a field through my view and everything were fine. When I want to enable, Edit and Delete links in my List.aspx I got the following error:  

    CS1061: 'ASP.dynamicdata_custompages_users_list_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.dynamicdata_custompages_users_list_aspx' could be found (are you missing a using directive or an assembly reference?)

    I have to program that method?

    Friday, September 16, 2011 2:23 AM
  • User-330204900 posted

    see Rick Anderson's article here How to create an updateable view with ADO Entity Framework and with LINQ to SQL I personally do the insert using SPROCS, although there is an issue with this in EF at the moment L2S works fine though.

    Friday, September 16, 2011 3:47 AM
  • User109254540 posted

    Thank you sjnaughton. I followed the link but is not available. Do you know another similar link? I really need it.

    Friday, September 16, 2011 1:07 PM
  • User-330204900 posted

    Just fixed it the Editor here somtimes thinks a URL is relative to this site and makes it relative Yell I just fixed it and tested Smile

    Friday, September 16, 2011 1:15 PM
  • User109254540 posted

    Now I can see insert, update, delete and details links, but when I try to update I get an SQL exception because the action involve more than one table, I have the stored procedures working, How I can tell dynamic data to use my stored procedures?? 

    Saturday, September 17, 2011 1:01 AM
  • User109254540 posted

    thank you. Using SPROCS I can insert in my view. 

    Monday, September 19, 2011 3:11 AM
  • User-842507885 posted

    Dear friend,

    Please go to the below link, here you will find the exact answer.

    http://aspdotnetcodebook.blogspot.com/2008/04/showing-data-from-multiple-tables.html

    Monday, September 19, 2011 3:13 AM