selectedrow in datatable

C

cloud

I want to move the rows in datatable up and down....
Here is my code:

Dim dt As DataTable
dt = New DataTable("Example")

Dim dr As DataRow

Dim Name As DataColumn = New DataColumn("names")

'setting the datatype for the column
dt.Columns.Add(Name)

For j = 1 To 5
dr = dt.NewRow()
dr.Item(0) = j
dt.Rows.Add(dr)
next

dim ds as new Dataset()
ds = New DataSet()
ds.Tables.Add(dt)
DataGridView2.DataSource = ds.Tables(0)

the output is as below:
1
2
3
4
5

On button click i have to move the selected row in datagridview up or
down.
How to get the selectedrow in datatable ??
Thank you
 
C

cloud

I want to move the rows in datatable up and down....
Here is my code:

Dim dt As DataTable
dt = New DataTable("Example")

Dim dr As DataRow

Dim Name As DataColumn = New DataColumn("names")

'setting the datatype for the column
dt.Columns.Add(Name)

For j = 1 To 5
     dr = dt.NewRow()
     dr.Item(0) = j
     dt.Rows.Add(dr)
next

dim ds as new Dataset()
ds = New DataSet()
ds.Tables.Add(dt)
DataGridView2.DataSource = ds.Tables(0)

the output is as below:
1
2
3
4
5

On button click i have to move the selected row in datagridview up or
down.
How to get the selectedrow in datatable ??
Thank you

solved..thanks
 

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