Datagrid datarelation

L

lekhacnair

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
 
C

Chris Fulstow

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
 
C

Cor Ligthert [MVP]

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
 
L

lekhacnair

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top