470,849 Members | 1,208 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

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 1190
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Julio Sarmiento | last post: by
5 posts views Thread by Mikael Syska | last post: by
4 posts views Thread by hennovanrensburg | last post: by
reply views Thread by Chad Folden | last post: by
5 posts views Thread by Genojoe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.