473,666 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How Do I Grab Current Row PK in Datagrid?

Hello:

I have a datagrid that has a dataset bound to it. When the customer
selects a certain row in the grid, I would like to be able to grab the
PK for that row, so I can call the customer edit form and load the
textboxes with a SELECT based upon that PK. How do I do this? In
Foxpro, since cursors have global scope, I would just call the edit
form and load the textboxes from the current (selected) record.

Thanks!

Steven
Nov 16 '05 #1
5 1301
The datagrid has a CurrentCell property. CurrentCell is compose of a row
and an index value. YOu can use those (assuming the sort order is the same)
which will correspond the the row and column index of the table its bound
to.

So, if the PK Value was "Bill" and the PK was the first column in your
datatable.

You could the reference dataTable.Rows[DataGrid.Curren tRowIndex][PKName]
<Steven C> wrote in message
news:5u******** *************** *********@4ax.c om...
Hello:

I have a datagrid that has a dataset bound to it. When the customer
selects a certain row in the grid, I would like to be able to grab the
PK for that row, so I can call the customer edit form and load the
textboxes with a SELECT based upon that PK. How do I do this? In
Foxpro, since cursors have global scope, I would just call the edit
form and load the textboxes from the current (selected) record.

Thanks!

Steven

Nov 16 '05 #2
Thanks, Bill

This seems to return an object, while I need to return the actual PK
value. For Instance, I have:

int PK =
CustomersTable. Rows[grdCustomers.Cu rrentRowIndex]["customerno "];

But this throws an exception because it's trying to return an object,
not the integer value for the PK.

Steven
On Wed, 5 May 2004 16:44:24 -0400, "William Ryan eMVP" <do********@com cast.nospam.net > wrote: The datagrid has a CurrentCell property. CurrentCell is compose of a row
and an index value. YOu can use those (assuming the sort order is the same)
which will correspond the the row and column index of the table its bound
to.

So, if the PK Value was "Bill" and the PK was the first column in your
datatable.

You could the reference dataTable.Rows[DataGrid.Curren tRowIndex][PKName]
<Steven C> wrote in message
news:5u******* *************** **********@4ax. com...
Hello:

I have a datagrid that has a dataset bound to it. When the customer
selects a certain row in the grid, I would like to be able to grab the
PK for that row, so I can call the customer edit form and load the
textboxes with a SELECT based upon that PK. How do I do this? In
Foxpro, since cursors have global scope, I would just call the edit
form and load the textboxes from the current (selected) record.

Thanks!

Steven


Nov 16 '05 #3
Just cast it to whatever type the value of the PK is.
<Steven C> wrote in message
news:af******** *************** *********@4ax.c om...
Thanks, Bill

This seems to return an object, while I need to return the actual PK
value. For Instance, I have:

int PK =
CustomersTable. Rows[grdCustomers.Cu rrentRowIndex]["customerno "];

But this throws an exception because it's trying to return an object,
not the integer value for the PK.

Steven
On Wed, 5 May 2004 16:44:24 -0400, "William Ryan eMVP" <do********@com cast.nospam.net > wrote:
The datagrid has a CurrentCell property. CurrentCell is compose of a row
and an index value. YOu can use those (assuming the sort order is the

same)which will correspond the the row and column index of the table its bound
to.

So, if the PK Value was "Bill" and the PK was the first column in your
datatable.

You could the reference dataTable.Rows[DataGrid.Curren tRowIndex][PKName]
<Steven C> wrote in message
news:5u******* *************** **********@4ax. com...
Hello:

I have a datagrid that has a dataset bound to it. When the customer
selects a certain row in the grid, I would like to be able to grab the
PK for that row, so I can call the customer edit form and load the
textboxes with a SELECT based upon that PK. How do I do this? In
Foxpro, since cursors have global scope, I would just call the edit
form and load the textboxes from the current (selected) record.

Thanks!

Steven

Nov 16 '05 #4
Coolness!

Thanks for all your help. :)

Steven
On Wed, 5 May 2004 18:42:46 -0400, "William Ryan eMVP" <do********@com cast.nospam.net > wrote: Just cast it to whatever type the value of the PK is.
<Steven C> wrote in message
news:af******* *************** **********@4ax. com...
Thanks, Bill

This seems to return an object, while I need to return the actual PK
value. For Instance, I have:

int PK =
CustomersTable. Rows[grdCustomers.Cu rrentRowIndex]["customerno "];

But this throws an exception because it's trying to return an object,
not the integer value for the PK.

Steven
>On Wed, 5 May 2004 16:44:24 -0400, "William Ryan eMVP"<do********@co mcast.nospam.ne t> wrote:
>The datagrid has a CurrentCell property. CurrentCell is compose of a row
>and an index value. YOu can use those (assuming the sort order is the

same) >which will correspond the the row and column index of the table its bound
>to.
>
>So, if the PK Value was "Bill" and the PK was the first column in your
>datatable.
>
>You could the reference dataTable.Rows[DataGrid.Curren tRowIndex][PKName]
><Steven C> wrote in message
>news:5u******* *************** **********@4ax. com...
>> Hello:
>>
>> I have a datagrid that has a dataset bound to it. When the customer
>> selects a certain row in the grid, I would like to be able to grab the
>> PK for that row, so I can call the customer edit form and load the
>> textboxes with a SELECT based upon that PK. How do I do this? In
>> Foxpro, since cursors have global scope, I would just call the edit
>> form and load the textboxes from the current (selected) record.
>>
>> Thanks!
>>
>> Steven
>>
>>
>


Nov 16 '05 #5
glad it worked!
<Steven C> wrote in message
news:j6******** *************** *********@4ax.c om...
Coolness!

Thanks for all your help. :)

Steven
On Wed, 5 May 2004 18:42:46 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
Just cast it to whatever type the value of the PK is.
<Steven C> wrote in message
news:af******* *************** **********@4ax. com...
Thanks, Bill

This seems to return an object, while I need to return the actual PK
value. For Instance, I have:

int PK =
CustomersTable. Rows[grdCustomers.Cu rrentRowIndex]["customerno "];

But this throws an exception because it's trying to return an object,
not the integer value for the PK.

Steven

>On Wed, 5 May 2004 16:44:24 -0400, "William Ryan eMVP"

<do********@co mcast.nospam.ne t> wrote:

>The datagrid has a CurrentCell property. CurrentCell is compose of a row >and an index value. YOu can use those (assuming the sort order is the

same)
>which will correspond the the row and column index of the table its bound >to.
>
>So, if the PK Value was "Bill" and the PK was the first column in your
>datatable.
>
>You could the reference dataTable.Rows[DataGrid.Curren tRowIndex][PKName] ><Steven C> wrote in message
>news:5u******* *************** **********@4ax. com...
>> Hello:
>>
>> I have a datagrid that has a dataset bound to it. When the customer
>> selects a certain row in the grid, I would like to be able to grab the >> PK for that row, so I can call the customer edit form and load the
>> textboxes with a SELECT based upon that PK. How do I do this? In
>> Foxpro, since cursors have global scope, I would just call the edit
>> form and load the textboxes from the current (selected) record.
>>
>> Thanks!
>>
>> Steven
>>
>>
>

Nov 16 '05 #6

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

Similar topics

4
15177
by: Steve | last post by:
Visual Studio 2003 .Net / C# I have a datagrid, which is bound to a dataset at runtime when my page loads. When the user double clicks a row, I need to find out which row they have selected so I can pass the key value onto another page, which is showing me more details for the selected row. So in the double click event of the datagrid I have this code: DataRow CurrentRow = dsJobList.Tables.Rows;
1
2245
by: amber | last post by:
I have a datagrid, based on a dataview (filled with dataset data from SQL server). The dataview contains an ID field, but this field isn't in the datagrid. How can I get the ID associated with the current selected row in the datagrid? Possible? Thanks in advance,
6
13581
by: aaa | last post by:
Hi I am trying to create a read-only DataGrid that would always have current row selected. Currently, I am using method: public void SelectDataGridRow(DataGrid dg) { if (dg.CurrentRowIndex > -1) { dg.Select(dg.CurrentRowIndex);
3
1289
by: Mike L | last post by:
This is in a WinForm. How do I grab all the data in all the cells of the row the user selected OR all the data in all the cells if the user selects one of the cells in the row? What event should I put the code in?
3
2257
by: Carolyn Vo | last post by:
I have a datagrid in my web control class that I am trying to get the current rows displayed for. I have enabled paging on the datagrid so if the user is currently on page 3 of 8, and if I have allowed for the table to show only 5 rows at a time, for example, I want to get the 5 rows that are displayed on page 3 of 8. How do I do this???? Thanks!
0
954
by: Cato Lommerud | last post by:
I have a datagrid control that shows the result from an Acces View and I want to change the current record for other bound controls when the user clicks in the different rows in the datagrid. Since the datagrid only contains a subset of the possible current records for the bound controls. Since the datagrid only shows a subset of the records, I can't use the current row as the position in the binding context, but I have the primary key...
10
4941
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
0
1376
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 datagridForm from my mainForm:
0
827
by: Holmsey | last post by:
Hello, I have a VB.net webform which shows a DataGrid that is actually a query of 3 tables with the results shown together. I need to be able to take 2 values out of a row when a user clicks the button associated with the row. I have been able to use Key= datagrid1.datakeys(e.item.itemindex) to get one of the values but I cannot figure out how to retrive the value in the same row that is right next to this value. In VBA you could use an...
0
8454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8363
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8645
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5672
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
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 we have to send another system
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.