By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,213 Members | 2,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,213 IT Pros & Developers. It's quick & easy.

How do you set the current row in a dataset

P: n/a
How do you set the current row of a dataset?
I want to bind a control to a field from the 5th row in a dataset.
I fill the dataset, then I want to set the row to the 5th row and then do
the databinding.

Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

'Sets the value for a field using index number......
Dataset1.tblMyTable(1).FieldName = strName

'Iterates through rows of a dataset but does not set the row
explicitly......
For Each myRow In DataSet1.tblMyTable.Rows
strName = myRow("FieldName")
Next
Nov 18 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Make a DataView that will contain only the row you want to show and bind
your control to the DataView.

Eliyahu

"Craig" <no****@austin.rr.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
How do you set the current row of a dataset?
I want to bind a control to a field from the 5th row in a dataset.
I fill the dataset, then I want to set the row to the 5th row and then do
the databinding.

Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

'Sets the value for a field using index number......
Dataset1.tblMyTable(1).FieldName = strName

'Iterates through rows of a dataset but does not set the row
explicitly......
For Each myRow In DataSet1.tblMyTable.Rows
strName = myRow("FieldName")
Next

Nov 18 '05 #2

P: n/a
I understand how to do that but it does not do what I need.

The row I want to show is based on the "index" or row number. I may want to
show row 5 then row 100 then row 48. So I need to be able to set the current
row to 5.

How do I do that?
Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
Make a DataView that will contain only the row you want to show and bind
your control to the DataView.

Eliyahu

"Craig" <no****@austin.rr.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
How do you set the current row of a dataset?
I want to bind a control to a field from the 5th row in a dataset.
I fill the dataset, then I want to set the row to the 5th row and then do the databinding.

Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

'Sets the value for a field using index number......
Dataset1.tblMyTable(1).FieldName = strName

'Iterates through rows of a dataset but does not set the row
explicitly......
For Each myRow In DataSet1.tblMyTable.Rows
strName = myRow("FieldName")
Next


Nov 18 '05 #3

P: n/a
Dataset1.tblMyTable.Rows[5] or Dataset1.tblMyTable[5]

Is that what you are after?

Eliyahu

"Craig" <no****@austin.rr.com> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
I understand how to do that but it does not do what I need.

The row I want to show is based on the "index" or row number. I may want to show row 5 then row 100 then row 48. So I need to be able to set the current row to 5.

How do I do that?
Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
Make a DataView that will contain only the row you want to show and bind
your control to the DataView.

Eliyahu

"Craig" <no****@austin.rr.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
How do you set the current row of a dataset?
I want to bind a control to a field from the 5th row in a dataset.
I fill the dataset, then I want to set the row to the 5th row and then do the databinding.

Dataset1.tblMyTable.CurrentIndex = 5 or something like that maybe?

'Sets the value for a field using index number......
Dataset1.tblMyTable(1).FieldName = strName

'Iterates through rows of a dataset but does not set the row
explicitly......
For Each myRow In DataSet1.tblMyTable.Rows
strName = myRow("FieldName")
Next



Nov 18 '05 #4

P: n/a
Hi Craig,

How do you do that databinding for that 5th row, you makes me curious,

I assume it is aspnet, because if it is windowsform it is easy to tell
however that does not work on a webform.

Cor
Nov 18 '05 #5

P: n/a
I am using webforms.

I want to do a 'next page' or 'previous page' function using a web form I
was going to use the row number of the dataset and increment each time or
decrement it each time and rebind the form.

How would I do the 'next page' or 'previous page' functionality using a web
form?

I know I can refer to any row in a dataset but it seems ridiculous that I
can't set the row of a dataset.

Why doesn't the tool box have a next record navigation functionality built
in, Interdev did?
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OS**************@TK2MSFTNGP10.phx.gbl...
Hi Craig,

How do you do that databinding for that 5th row, you makes me curious,

I assume it is aspnet, because if it is windowsform it is easy to tell
however that does not work on a webform.

Cor

Nov 18 '05 #6

P: n/a
Are you using a datagrid?

The index is of course the way Eliyahy showed you.

So that I do not need to answer anymore.

Cor
Nov 18 '05 #7

P: n/a
No it is using textbox controls on a single page.

I have created a datagrid and set the paging to 1. That worked. But a
complex form can be easier as a webform full of controls.

So any ideas?
Name _________
Address _________

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Are you using a datagrid?

The index is of course the way Eliyahy showed you.

So that I do not need to answer anymore.

Cor

Nov 18 '05 #8

P: n/a
Hi Craig

In my opinion did you got the idea for that from Eliyahu.

Know that a dataset and your currentindex does not persist when you do not
set it in a session (or a viewstate or a cache, however the last should be a
nonchanging dataset).

Cor
Nov 18 '05 #9

P: n/a
Eliyahu said....

Make a DataView that will contain only the row you want to show and bind
your control to the DataView.
and...
Dataset1.tblMyTable.Rows[5] or Dataset1.tblMyTable[5]

I don't see how that helps. I just want to bind the controls to he first
row, then the user clicks a next button and then I'll bind the controls to
the next row etc. I don't care if the dataset has to be refilled etc. and
I'll maintain the current row in a ViewState("Currentrow") variable.

So how can I set the row number in the dataset?

Maybe I'll just stick to a datagrid with paging set to 1.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
Hi Craig

In my opinion did you got the idea for that from Eliyahu.

Know that a dataset and your currentindex does not persist when you do not
set it in a session (or a viewstate or a cache, however the last should be a nonchanging dataset).

Cor

Nov 18 '05 #10

P: n/a
Hi Craig

I translate Eliyahus answer to your question when you using C# in vb.net
the [] are ()
Dataset1.tblMyTable.Rows[Currentrow] or Dataset1.tblMyTable[Currentrow]

Or in complete dataset now VB.net
Dataset1.tables(0).Rows(Currentrow)

Cor
Nov 18 '05 #11

P: n/a
Doesn't that just refer to the row but does not set the pointer to a row in
the dataset?
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ur****************@TK2MSFTNGP09.phx.gbl...
Hi Craig

I translate Eliyahus answer to your question when you using C# in vb.net
the [] are ()
Dataset1.tblMyTable.Rows[Currentrow] or Dataset1.tblMyTable[Currentrow]

Or in complete dataset now VB.net
Dataset1.tables(0).Rows(Currentrow)

Cor

Nov 18 '05 #12

P: n/a
Hi Craig,
Doesn't that just refer to the row but does not set the pointer to a row in

the dataset?

As far as I know there is no pointer to a row in a dataset.

In windowforms there is for this the curencymanager, however as far as I
know you cannot use the currencymanager in an webpage.

Otherwise it was in VB something as

Directcast(Bindingcontext(dataset),currencymanager ).position = curindex

Cor
Nov 18 '05 #13

P: n/a
That's right. But you don't have to bind to the dataset. You can bind to any
property. So, all you have to do is just to wrap
Dataset1.tables(0).Rows(Currentrow) into a property and use the property
name in the data-binding expression of your textbox.

Eliyahu

"Craig" <no****@austin.rr.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
Doesn't that just refer to the row but does not set the pointer to a row in the dataset?
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ur****************@TK2MSFTNGP09.phx.gbl...
Hi Craig

I translate Eliyahus answer to your question when you using C# in vb.net the [] are ()
Dataset1.tblMyTable.Rows[Currentrow] or Dataset1.tblMyTable[Currentrow]

Or in complete dataset now VB.net
Dataset1.tables(0).Rows(Currentrow)

Cor


Nov 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.