473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do you set the current row in a dataset

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
13 1676
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Craig | last post by:
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...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
3
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew =...
4
by: Joel | last post by:
Hi! Its probably a stupid question but how can I retreive the column of the current row? Example: This retreive the value in the ID column for the first row. dstForeignKey.Tables(0).Rows(0)("ID")...
0
by: Ben | last post by:
module main ... application.run(new splashform) .. end module after a few screen, I try to load a new codes I got from MSDN on datagrid that works on its own. I took out submain and ran...
1
by: Larry Lard | last post by:
I've got a Windows Forms app talking to an Access db, and I'm experimenting with VS2005's form data binding stuff etc. I've got a dataset, a datagridview bound to a query (let's call it...
4
by: Keith G | last post by:
VS2003 I am using a datagrid on a Windows form. The user has 2 buttons: cancel the current changes (re-loads the dataset) or update (updates the dataset). The problem is that any edits in the...
7
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get...
6
by: =?Utf-8?B?emlubw==?= | last post by:
in asp.net 2, I load a dataset from the Cache object into a local object to use to perform processing. I had been using httpcontext.current.cache and what I noticed is sometime I'm not able to get...
0
by: alister7 | last post by:
hi every1 im trying to download a music file from the database SQLserver.which i upload in the database.. The Code below works fine in wen i create a new project of an ASP.Net web application..m...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.