Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2004, 01:22 AM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zouky
Default currency manager

dear expert
as i know there's something in .NET framework call currency manager used for navigating dataset, how do i use it in ASP.NET if i want to use it as something like cursor pointing on my dataset where by i can move top, move next, move pervious and last.

thank you

 
Old October 8th, 2004, 04:25 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know how to use Currency Managaer in C#, and I am not sure about ASP.NET

DataView dv;
DataSet dataset11;
sqlDataAdapter1.Fill(dataSet11);
Grid.DataSource = dataset11.Tables[0];
dv = new DataView(dataSet11.Tables[0]);
dv.Sort="SupplierID";
CM =(CurrencyManager) BindingContext[Grid.DataSource];
int x = dv.Find(Int32.Parse(textBox2.Text));
if (x>=0)
{
CM.Position=x;
}

Explanation

1) Connect to DB
2) Fill the dataset using data adapter
3) Set the data source for the grid to display data on the grid
4) Create a dataview using the same data source
dv = new DataView(dataSet11.Tables[0]);

5) Set the sort property of the dataview using a column name of the data source. The column name should be the column by which you want to serach the grid for values

dv.Sort="SupplierID";

So now we have the searchable data grid and we can search the date gird and find the position of row using the following line

dv.Find(value) --> This seraches the dataview for the value and returns the record index. If the record not found then it returns -1.

After having searchable data grid, use the currency manager to bind to grid and position at particular record.To position the cursor in the grid for the searched value follow the below steps

1) Get the Binding context of the grid source and store it on the currency manager

CM =(CurrencyManager) BindingContext[Grid.DataSource];

2) Use the find method to get the record index.
3) If it is a valid index then set the property of Currency manager "position" property to scroll in to searched record in the data grid.

CM.Position=x;





It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old December 12th, 2005, 05:20 AM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thnx man that reall helped me in vb.net
here is the code for others

If txtfind.Text.Trim = "" Then
                Exit Sub
            End If

            Dim objTimeSheets As DataSet
            objTimeSheets = New TimeSheets

            'Attempt to fill the temporary dataset.
            Me.FillDataSet(objTimeSheets)

            Dim x As Integer

            Dim cm As CurrencyManager
            dim dg as datagid
            ''its better to ccreate the datagrid at design time
            dg.DataSource = Nothing

            dg.DataSource = objTimeSheets
            Dim dv As DataView = New DataView(objTimeSheets.Tables("TimeSheet"))

''sort the view here
            dv.Sort = "TimeSheetNo"

''use the currency manager
            cm = CType(Me.BindingContext(dv), CurrencyManager)
            x = 0

            x = dv.Find(txtfind.Text.Trim)
            If (x >= 0) Then
                MsgBox(x)
            Else
                MsgBox("Values Not Found,Try Again!", MsgBoxStyle.Information)

                Exit Sub
            End If







Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting currency drmacy BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 September 20th, 2007 04:59 PM
Currency Format kdkcchoco ASP.NET 1.0 and 1.1 Professional 1 March 29th, 2007 08:13 AM
Currency mjbkelly Beginning VB 6 1 March 22nd, 2007 07:14 AM
Currency value in textboxes mahulda ASP.NET 1.0 and 1.1 Basics 1 April 6th, 2004 02:10 PM
currency codes jgcvasquez VB Databases Basics 3 February 28th, 2004 02:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.