Edit a row

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

    #1

    Edit a row

    Hi,
    I am a vb.net novice. I have a datatable which is populated with the
    data from sql query.
    dt = datastore.GetDa taTable(GetSql( uid, bin))
    I want to edit each row in the datatable with new values but before
    they are binded to the datagrid. what would be the best way to do it.
    Any leads would be great
    thanks
    Jay

  • Kerry Moorman

    #2
    RE: Edit a row

    Jay,

    You could use a For Each loop to process each row.

    For Each dr As DataRow in dt.Rows
    'Process row dr
    Next

    Kerry Moorman


    "jayasunderam@g mail.com" wrote:
    Hi,
    I am a vb.net novice. I have a datatable which is populated with the
    data from sql query.
    dt = datastore.GetDa taTable(GetSql( uid, bin))
    I want to edit each row in the datatable with new values but before
    they are binded to the datagrid. what would be the best way to do it.
    Any leads would be great
    thanks
    Jay
    >
    >

    Comment

    • Jay

      #3
      Re: Edit a row

      I am updating the rows by getting values from another array. the array
      is not sorted. I am not sure in which order the array will have
      data.therefore i need to read the data from array and update the
      corresponding row in the table.
      any suggestions
      thanks

      Kerry Moorman wrote:
      Jay,
      >
      You could use a For Each loop to process each row.
      >
      For Each dr As DataRow in dt.Rows
      'Process row dr
      Next
      >
      Kerry Moorman
      >
      >
      "jayasunderam@g mail.com" wrote:
      >
      Hi,
      I am a vb.net novice. I have a datatable which is populated with the
      data from sql query.
      dt = datastore.GetDa taTable(GetSql( uid, bin))
      I want to edit each row in the datatable with new values but before
      they are binded to the datagrid. what would be the best way to do it.
      Any leads would be great
      thanks
      Jay

      Comment

      • Kerry Moorman

        #4
        Re: Edit a row

        Jay,

        You could sort both the datatable and the array on the same data element.

        Or you could create a dataview from the datatable and use its Find method to
        find the row that matches data from the array.

        Kerry Moorman


        "Jay" wrote:
        I am updating the rows by getting values from another array. the array
        is not sorted. I am not sure in which order the array will have
        data.therefore i need to read the data from array and update the
        corresponding row in the table.
        any suggestions
        thanks
        >
        Kerry Moorman wrote:
        Jay,

        You could use a For Each loop to process each row.

        For Each dr As DataRow in dt.Rows
        'Process row dr
        Next

        Kerry Moorman


        "jayasunderam@g mail.com" wrote:
        Hi,
        I am a vb.net novice. I have a datatable which is populated with the
        data from sql query.
        dt = datastore.GetDa taTable(GetSql( uid, bin))
        I want to edit each row in the datatable with new values but before
        they are binded to the datagrid. what would be the best way to do it.
        Any leads would be great
        thanks
        Jay
        >
        >
        >
        >

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Edit a row

          Kerry,

          You are using a strongly typed datatable, that one is forever inherited from
          a non strongly typed datatable

          The main format of that is that it are two collection.
          DataRows
          DataColumns

          DataRows have items which are described in the datacolumns.

          You can forever get an item as
          DataTable.DataR ows(TheRowIndex ).Item(TheDataC olumnName or the "DataItemna me"
          or the Index)

          This patern is of course as well in the strongly dataset. Most people don't
          like to use the strongly typed datsets to do updating as you do, because
          getting the right row is forever troublefull. Therefore cast it to a
          standard datatable and use that.

          I hope this gives an idea,

          Cor

          "Kerry Moorman" <KerryMoorman@d iscussions.micr osoft.comschree f in bericht
          news:AF6FD686-CB18-45C4-A7A8-8B9A673E2028@mi crosoft.com...
          Jay,
          >
          You could sort both the datatable and the array on the same data element.
          >
          Or you could create a dataview from the datatable and use its Find method
          to
          find the row that matches data from the array.
          >
          Kerry Moorman
          >
          >
          "Jay" wrote:
          >
          >I am updating the rows by getting values from another array. the array
          >is not sorted. I am not sure in which order the array will have
          >data.therefo re i need to read the data from array and update the
          >correspondin g row in the table.
          >any suggestions
          >thanks
          >>
          >Kerry Moorman wrote:
          Jay,
          >
          You could use a For Each loop to process each row.
          >
          For Each dr As DataRow in dt.Rows
          'Process row dr
          Next
          >
          Kerry Moorman
          >
          >
          "jayasunderam@g mail.com" wrote:
          >
          Hi,
          I am a vb.net novice. I have a datatable which is populated with the
          data from sql query.
          dt = datastore.GetDa taTable(GetSql( uid, bin))
          I want to edit each row in the datatable with new values but before
          they are binded to the datagrid. what would be the best way to do it.
          Any leads would be great
          thanks
          Jay
          >
          >
          >>
          >>

          Comment

          • Jay

            #6
            Re: Edit a row

            thanks people i fixed the problem. I appreciate everyone's feedback
            Jay
            Cor Ligthert [MVP] wrote:
            Kerry,
            >
            You are using a strongly typed datatable, that one is forever inherited from
            a non strongly typed datatable
            >
            The main format of that is that it are two collection.
            DataRows
            DataColumns
            >
            DataRows have items which are described in the datacolumns.
            >
            You can forever get an item as
            DataTable.DataR ows(TheRowIndex ).Item(TheDataC olumnName or the "DataItemna me"
            or the Index)
            >
            This patern is of course as well in the strongly dataset. Most people don't
            like to use the strongly typed datsets to do updating as you do, because
            getting the right row is forever troublefull. Therefore cast it to a
            standard datatable and use that.
            >
            I hope this gives an idea,
            >
            Cor
            >
            "Kerry Moorman" <KerryMoorman@d iscussions.micr osoft.comschree f in bericht
            news:AF6FD686-CB18-45C4-A7A8-8B9A673E2028@mi crosoft.com...
            Jay,

            You could sort both the datatable and the array on the same data element.

            Or you could create a dataview from the datatable and use its Find method
            to
            find the row that matches data from the array.

            Kerry Moorman


            "Jay" wrote:
            I am updating the rows by getting values from another array. the array
            is not sorted. I am not sure in which order the array will have
            data.therefore i need to read the data from array and update the
            corresponding row in the table.
            any suggestions
            thanks
            >
            Kerry Moorman wrote:
            Jay,

            You could use a For Each loop to process each row.

            For Each dr As DataRow in dt.Rows
            'Process row dr
            Next

            Kerry Moorman


            "jayasunderam@g mail.com" wrote:

            Hi,
            I am a vb.net novice. I have a datatable which is populated with the
            data from sql query.
            dt = datastore.GetDa taTable(GetSql( uid, bin))
            I want to edit each row in the datatable with new values but before
            they are binded to the datagrid. what would be the best way to do it.
            Any leads would be great
            thanks
            Jay
            >
            >
            >
            >

            Comment

            Working...