Datagrid datarelation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lekhacnair@gmail.com

    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_Deta ils As New DataTable
    Validation_Deta ils = data2.Tables(0)
    data.Tables.Add (Case_Details.C opy())
    data.Tables.Add (Validation_Det ails.Copy())

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

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

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

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

    Thanks,
    Lek

  • Chris Fulstow

    #2
    Re: Datagrid datarelation

    Hi Lek,

    You can use a calculated column to do this:

    DataColumn count = new DataColumn("Vis it count", GetType(int),
    COUNT(Child(Cas e2Validation).V isit_ID))

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

    HTH,

    Chris

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Datagrid datarelation

      Chris,
      [color=blue]
      >
      > You can use a calculated column to do this:
      >
      > DataColumn count = new DataColumn("Vis it count", GetType(int),
      > COUNT(Child(Cas e2Validation).V isit_ID))
      >
      > Then simply add the column to your table using DataTable.Colum ns.Add().
      >[/color]
      Nice one, do you have a problem if I set this on our website for the next
      time.

      Although than DataTable.Colum ns.Add(TheCount ) or direct.

      Cor



      Comment

      • Chris Fulstow

        #4
        Re: Datagrid datarelation

        No problem - post me the link :)
        Chris

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Datagrid datarelation



          "Chris Fulstow" <chrisfulstow@h otmail.com> schreef in bericht
          news:1144941699 .759283.223640@ t31g2000cwb.goo glegroups.com.. .[color=blue]
          > No problem - post me the link :)
          > Chris
          >[/color]


          Comment

          • lekhacnair@gmail.com

            #6
            Re: Datagrid datarelation

            Thanks Chris,

            Let me try this and will post the outcome.

            Lek

            Comment

            • lekhacnair@gmail.com

              #7
              Re: Datagrid datarelation

              Hi Chris,

              Asp.net is not liking it. I created
              Dim count As DataColumn = New DataColumn("Vis it count",
              GetType(System. Int32), count(Child(Cas e2Validation).V isit_ID))

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


              Thanks,
              Lekha

              Comment

              • Chris Fulstow

                #8
                Re: Datagrid datarelation

                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("Vis it count",
                GetType(System. Int32), "count(Child(Ca se2Validation). Visit_ID)")

                More info on MSDN:


                Cheers,
                Chris

                Comment

                Working...