This is a migrated thread and some comments may be shown as answers.

How to get value from 3rd table in gridview

4 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thanh
Top achievements
Rank 1
Thanh asked on 30 Jan 2011, 01:41 AM
I am using Gridview (Hierarchy) to display data from the database Northwind with a small modification:
- table Orders has following columns: OrderID, OrderDate
- table Details has: DetailsID, OrderID, ProductID, Quantity, UnitPrice, Total (Total is one column in Gridview using expression)
- table Products has: ProductID, ProductName, TaxID
- table Tax has: TaxID, Tax
The Orders table is parent table and the Details table is child table. With the ProductID and GridviewComboboxColumn I can display ProductName from the Products table, but I don't know how to get the Tax value from table Tax using the same method to complete the goal: Total=Quantity*UnitPrice*(1+Tax).
Do you have any idea to do that?
Any help would be appreciated.
Thanh Ho

4 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 30 Jan 2011, 10:14 AM
Hello,

Please take a look at my answer in this forum post which should help. If you need anything further though, just let me know.
Richard
0
Thanh
Top achievements
Rank 1
answered on 30 Jan 2011, 01:22 PM
Hello Richard,
thanks for your reply.
I've looked at your answer in the other post but thats not what I am looking for. It is possible that my description was a little bit confusing. So I will describe it again.
In my first post I have described a part of my database. I'd like to display in gridview the Orders table as parent and Details as child, with Relation: OrderID - OrderID. Now in the child template I'd like to display the following fields: Productname, Quantity, Unitprice, Tax, Total. In the table Details in database I have ProductID, so I can display the Productname with the help from ComboboxColumn (I set Datasource=Products, Displaymember=Productname, Field=ProductID, Valuemember=ProductID). Yes, it's easy.
But now I'd like to get the Tax value from the Tax table according to the ProductID, so that I can at the end calculate the total value for this Product as TotalColumn.Expression="Quantity*Unitprice*(1+Tax)". Is there any way to complete this task?
Thanks for your help.
Thanh Ho
0
Richard Slade
Top achievements
Rank 2
answered on 30 Jan 2011, 11:11 PM
Hello,

Unfortunatly, I don't have a Northwind data base to be able to look into this for you. But it sounds like you need to make some joins on your tables to bring back the data that will include the data that you need. Apologies if I have mis-understood your request, but if there is anything further that you think I can help with, just let me know
Regards,
Richard
0
Thanh
Top achievements
Rank 1
answered on 31 Jan 2011, 03:59 PM
Hello,
using join won't help in my case, but I will try to find other approaches.
Thank you anyway.
Thanh Ho
Tags
GridView
Asked by
Thanh
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Thanh
Top achievements
Rank 1
Share this question
or