473,513 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Move to next DataSet row

Hi All,

I'm using the following to fill a DataSet:

public void itemSearch(string column, string item)
{
...fill DataSet
}

I want to be able to move to the next and previous rows with:

private void cmdNext_Click(object sender, EventArgs e)
{
BindingContext[ds.Tables[0]].Position += 1;
}

The problem is the DataSet (ds) isn't accessible. I'm a novice here
but thought that since the Dataset method was public I'd be able to
access it.

How can I do that?

Thanks for any insight.

Jul 2 '07 #1
4 5573
Looch,

You should have a field somewhere that the cmdNext_Click method can
access which holds the data source that you are getting the binding context
for. In other words, you should change your design to return an object and
a string (optionally, for the DataMember) which you can use to get the
binding context.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Looch" <lu**********@yahoo.comwrote in message
news:11**********************@q69g2000hsb.googlegr oups.com...
Hi All,

I'm using the following to fill a DataSet:

public void itemSearch(string column, string item)
{
...fill DataSet
}

I want to be able to move to the next and previous rows with:

private void cmdNext_Click(object sender, EventArgs e)
{
BindingContext[ds.Tables[0]].Position += 1;
}

The problem is the DataSet (ds) isn't accessible. I'm a novice here
but thought that since the Dataset method was public I'd be able to
access it.

How can I do that?

Thanks for any insight.

Jul 2 '07 #2
I'm guessing, but I believe this is because your dataset is not visible from
the scope you show. Define a protected DataSet ds field at class level (not
inside any method), and when you get back your DataSet, assign it to this
field. It should now be "visible" from within any method of your class.

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Looch" wrote:
Hi All,

I'm using the following to fill a DataSet:

public void itemSearch(string column, string item)
{
...fill DataSet
}

I want to be able to move to the next and previous rows with:

private void cmdNext_Click(object sender, EventArgs e)
{
BindingContext[ds.Tables[0]].Position += 1;
}

The problem is the DataSet (ds) isn't accessible. I'm a novice here
but thought that since the Dataset method was public I'd be able to
access it.

How can I do that?

Thanks for any insight.

Jul 2 '07 #3
Define a protected DataSet ds field at class level (not
inside any method), and when you get back your DataSet, assign it to
this
field.

Peter, could you provide a quick example? I'm not sure what you mean
by field.
Jul 3 '07 #4
public class MyClass
{
protected DataSet myDs;

public void GetDataSet ()
{
// your database call to get back DataSet here
myDs=SqlHelper.ExecuteDataSet (myconn, mysproc, myparams);
}

// now "myDs" is visible from any method in your class, once its been
populated and assigned to the "myDs" variable.
}

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Looch" wrote:
Hi All,

I'm using the following to fill a DataSet:

public void itemSearch(string column, string item)
{
...fill DataSet
}

I want to be able to move to the next and previous rows with:

private void cmdNext_Click(object sender, EventArgs e)
{
BindingContext[ds.Tables[0]].Position += 1;
}

The problem is the DataSet (ds) isn't accessible. I'm a novice here
but thought that since the Dataset method was public I'd be able to
access it.

How can I do that?

Thanks for any insight.

Jul 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2254
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
4
2862
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
1
1656
by: grs | last post by:
What is the recommended method of moving datsets around in code. Do you use 1 or 2 below or does it make a difference. 1. public void CreateDataSet(DataSet aDataset) or 2. public DataSet...
4
2698
by: David Hearn | last post by:
I am trying to build a few pages basically emulating a wizard that you might find in a Windows product. A few fields to fill out on one page, move to the next, then the next. Finally, at the end,...
7
3069
by: tshad | last post by:
Is there a way to move a row in a Datalist up or down without having to re-read the data? I have a datalist which has embedded Datagrids in it. I want to allow the user to move a row up or down...
2
1516
by: Shapper | last post by:
Hello, I have a dataset in an ASP.NET/VB web page: Function dsNews() As System.Data.DataSet Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data...
1
2040
by: Sam | last post by:
Hi, How can I move a row in my dataview to the first position ? Thx
2
18221
TMS
by: TMS | last post by:
Schools over!!! Now its time to play. I would like to learn how to make objects move from one location to the next on a canvas widget. For example: from Tkinter import * class square:...
3
5434
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
0
7254
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
7373
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
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
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...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.