473,412 Members | 2,012 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,412 software developers and data experts.

getting value of current record

I have a form with a datagrid and a dataset bound to it. I want to launch a
second form and pass it a value from whichever record the user has selected.
I can't find an example anywhere that shows me how to do this. I know how to
launch the 2nd form and how to make a public variable to hold the value but
I can't figure out how to get the value.

In Delphi what I need should be something like
dataSet1.FieldByName('UserID').Value;

Is there an easy way to get this in .NET? Do I need a currency manager or
something complicated like that?
Nov 16 '05 #1
2 2345
CurrencyManagers aren't complicated and exist whether you want them or not
;-). However, you don't need to specifically address it.

If the order of the underlying table matches the grid (ie it hasn't been
sorted) you can use

DataRow dr;
dr = dataSetName.Tables["Whatever"].Rows[DataGrid.CurrentRowIndex];

you can reference a specific value in a column by adding a reference
Rows[0][1] for instance. (Although you need to do a cast to wahtever type
the value is).

Youy can also use DataGrid[0,1] or use the CurrentRowIndex
/CurrentColumnIndex to get that info.

There's another property of the Grid, IsSelected that will indicate if the
row is Selected or not that may help you in this endeavor.

HTH,

Bill

www.devbuzz.com
www.knowdotnet.com
"Red Green" <re*@green.com> wrote in message
news:OG**************@TK2MSFTNGP11.phx.gbl...
I have a form with a datagrid and a dataset bound to it. I want to launch a second form and pass it a value from whichever record the user has selected. I can't find an example anywhere that shows me how to do this. I know how to launch the 2nd form and how to make a public variable to hold the value but I can't figure out how to get the value.

In Delphi what I need should be something like
dataSet1.FieldByName('UserID').Value;

Is there an easy way to get this in .NET? Do I need a currency manager or
something complicated like that?

Nov 16 '05 #2
Thanks. I tried :

int ThisRec;
ThisRec =
(int)dataSet11.Tables["SpClientsByCompany"].Rows[dataGrid1.CurrentRowIndex][
o];

which seems to work OK but what if the grid is sorted? Is there not some
sort of cursor that moves through the dataset as the user moves through the
gird? As the grid knows how to edit data it must be tracking where it is in
relation to the dataset? Is that what a currency manager does?

I found a web page that says: The CurrencyManager object monitors the
position and otherwise supervises bindings to that data source.

If this is the case then is seems that

cm =
(CurrencyManager)this.BindingContex[dataSet11.Tables["SpClientsByCompany"]];
int This Rec
ThisRec = (int)dataSet11.Tables['SpClientsByCompany'].Rows[cm.Position][0];

should work even is the grid is sorted but it always returns the same value.

It seems like displaying two forms with related data is something every real
world database program must do so I am surprised that I cannot find and
example of it anywhere.
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
CurrencyManagers aren't complicated and exist whether you want them or not ;-). However, you don't need to specifically address it.

If the order of the underlying table matches the grid (ie it hasn't been
sorted) you can use

DataRow dr;
dr = dataSetName.Tables["Whatever"].Rows[DataGrid.CurrentRowIndex];

you can reference a specific value in a column by adding a reference
Rows[0][1] for instance. (Although you need to do a cast to wahtever type
the value is).

Youy can also use DataGrid[0,1] or use the CurrentRowIndex
/CurrentColumnIndex to get that info.

There's another property of the Grid, IsSelected that will indicate if the
row is Selected or not that may help you in this endeavor.

HTH,

Bill

www.devbuzz.com
www.knowdotnet.com
"Red Green" <re*@green.com> wrote in message
news:OG**************@TK2MSFTNGP11.phx.gbl...
I have a form with a datagrid and a dataset bound to it. I want to launch
a
second form and pass it a value from whichever record the user has selected.
I can't find an example anywhere that shows me how to do this. I know

how to
launch the 2nd form and how to make a public variable to hold the value

but
I can't figure out how to get the value.

In Delphi what I need should be something like
dataSet1.FieldByName('UserID').Value;

Is there an easy way to get this in .NET? Do I need a currency manager

or something complicated like that?


Nov 16 '05 #3

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

Similar topics

33
by: n00m | last post by:
import socket, thread host, port = '192.168.0.3', 1434 s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s2.connect((host, 1433))...
2
by: Douglas Buchanan | last post by:
This is a mystery! Why does the boolean value of a record change without my input. What follows describes the situation and the behavior. Table1: Field1: Text Field2: Yes/No Form1 has two...
3
by: William Wisnieski | last post by:
Hello Again, I'm really stuck on this one.....so I'm going to try a different approach to this problem. I have a query by form that returns a record set in a datasheet. The user double...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
2
by: ThompsonJessical | last post by:
I am trying to use a button with the vba coding for SendObject Function to email a specific report based on the value of another field of the current record. The form is a continuous form and...
3
by: Jason L James | last post by:
Hi all, I recently wrote a vb.net app using oledb to an access database. When I inserted new rows in my datatable the identity column was automatically created. This app used an un-typed...
8
by: BB | last post by:
Hi, I am using FormView Contol, TextBox (Hidden ) and Submit button whose caption is "View Page" in my aspx page. Here is what I am tryin to do.When page loads I generate dynamic url in text box...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
7
by: shalskedar | last post by:
In a query i want to retrieve the value in such a way that if the value for the current record for a given column is 0 then it should go to the next record & take the value. for ex-I 've column...
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
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
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...
0
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
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.