473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Datagrid datarelation

Hello,

I am stuck with my datagrid datarelation.

My code looks like this:

Dim Case_Details As New DataTable
Case_Details = data1.Tables(0)
Dim Validation_Details As New DataTable
Validation_Details = data2.Tables(0)
data.Tables.Add(Case_Details.Copy())
data.Tables.Add(Validation_Details.Copy())

Dim dc1 As DataColumn =
data.Tables(0).Columns("facility_visit_id")

Dim dc2 As DataColumn = data.Tables(1).Columns("Visit_ID")

Dim rel As New DataRelation("Case2Validation", dc1, dc2,
True)

How do I get the count of child rows each parent has?

Thanks,
Lek

Apr 13 '06 #1
7 1276
Hi Lek,

You can use a calculated column to do this:

DataColumn count = new DataColumn("Visit count", GetType(int),
COUNT(Child(Case2Validation).Visit_ID))

Then simply add the column to your table using DataTable.Columns.Add().

HTH,

Chris

Apr 13 '06 #2
Chris,

You can use a calculated column to do this:

DataColumn count = new DataColumn("Visit count", GetType(int),
COUNT(Child(Case2Validation).Visit_ID))

Then simply add the column to your table using DataTable.Columns.Add().

Nice one, do you have a problem if I set this on our website for the next
time.

Although than DataTable.Columns.Add(TheCount) or direct.

Cor

Apr 13 '06 #3
No problem - post me the link :)
Chris

Apr 13 '06 #4
http://www.vb-tips.com/default.aspx?...8-7ab8d0952728

"Chris Fulstow" <ch**********@hotmail.com> schreef in bericht
news:11**********************@t31g2000cwb.googlegr oups.com...
No problem - post me the link :)
Chris

Apr 13 '06 #5
Thanks Chris,

Let me try this and will post the outcome.

Lek

Apr 13 '06 #6
Hi Chris,

Asp.net is not liking it. I created
Dim count As DataColumn = New DataColumn("Visit count",
GetType(System.Int32), count(Child(Case2Validation).Visit_ID))

I am getting the error child and Case2Validation are not delcared.
Thanks,
Lekha

Apr 13 '06 #7
Hi Lekha,

Sorry, the third parameter is the expression and should be a string.
I'm more of a C# programmer so it lost a bit in the translation :)

Dim count As DataColumn = New DataColumn("Visit count",
GetType(System.Int32), "count(Child(Case2Validation).Visit_ID)")

More info on MSDN:
http://msdn2.microsoft.com/en-us/lib...b6(VS.80).aspx

Cheers,
Chris

Apr 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Julio Sarmiento | last post by:
Can anyone help me???? I have a table that I need to get the sum of four individual fields and then rank them from highest to lowest total. After summing up the four fields individually and...
1
by: Brian | last post by:
I have a dataset containing 2 tables. I need to fill a datagrid using data from both of these. If I could create a SQL Statement to fill the datagrid, it would look like this: SELECT...
5
by: Mikael Syska | last post by:
Hi, I have 2 talbes in a DataSet, and made a DataRelation between the 2 tables in the DataSet. One of the Tables are displayed in a datagrid, and when one of them is selected in the datagrid...
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
4
by: hennovanrensburg | last post by:
Hi all, I've noted a couple of posts regarding the speed of a datagrid in a ..net win app. My datagrid consists of 37 rows and 12 cols, and is unacceptably slow. How can this be? Should I...
0
by: Chad Folden | last post by:
I can't figure out how to use the EditCommand for the nested datagrid .. HELP PLEASE ;-) It works perfectly for the parent datagrid, but will not display, even though the EditCommand event is...
5
by: Genojoe | last post by:
I am using code from Help with two exceptions. (1) I increased the number of sample rows from 3 to 20, and (2) I anchored the datagrid to bottom of form so that I can change the size of the grid by...
1
by: Agnes | last post by:
In my one datagrid, there is master - detail relationship. I can set dv.allownew = false, However, as the user click into detail, it can't set to allownew = false. Does anyone know how to solve it...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: KA NMC | last post by:
I have One Datagrid with a dataset that calls two tables - the First table is the table the user will be editing - which edited on the grid or in a textbox - as the user edits the grid - that info is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.