How to add datarow in existing datatable? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to add datarow in existing datatable?

GeekProgrammerGeekProgrammer Posts: 1Member
I have a datatable with several columns.During run time i added a column ,now i want to add rows to it.Can any one suggest how to add rows to that particular datacolumn

Comments

  • EazyTalkIncEazyTalkInc Posts: 6Member
    [code]'test datatable
    Dim dt As New DataTable
    dt.Columns.Add("col1")
    dt.Columns.Add("col2")

    'add new row
    Dim dr As DataRow
    dr = dt.NewRow()
    dr.Item(0) = "row1col1"
    dr.Item(1) = "row1col2"
    dt.Rows.Add(dr)

    'add dynamic column
    dt.Columns.Add("col3")

    'add value to column
    dr.Item(2) = "row1col3"
    [/code]
    ________________________________________________________
    www.eazytalkinc.com
  • EazyTalkIncEazyTalkInc Posts: 6Member
    .....
    ________________________________________________________
    www.eazytalkinc.com
Sign In or Register to comment.