PC Review


Reply
Thread Tools Rate Thread

How Do I Grab Current Row PK in Datagrid?

 
 
Steven C
Guest
Posts: n/a
 
      5th May 2004
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


 
Reply With Quote
 
 
 
 
William Ryan eMVP
Guest
Posts: n/a
 
      5th May 2004
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.CurrentRowIndex][PKName]
<Steven C> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Steven C
Guest
Posts: n/a
 
      5th May 2004
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.CurrentRowIndex]["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" <(E-Mail Removed)> 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.CurrentRowIndex][PKName]
><Steven C> wrote in message
>news:(E-Mail Removed)...
>> 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
>>
>>

>


 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      5th May 2004
Just cast it to whatever type the value of the PK is.
<Steven C> wrote in message
news:(E-Mail Removed)...
> 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.CurrentRowIndex]["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"

<(E-Mail Removed)> 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.CurrentRowIndex][PKName]
> ><Steven C> wrote in message
> >news:(E-Mail Removed)...
> >> 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
> >>
> >>

> >

>



 
Reply With Quote
 
Steven C
Guest
Posts: n/a
 
      6th May 2004
Coolness!

Thanks for all your help.

Steven

>On Wed, 5 May 2004 18:42:46 -0400, "William Ryan eMVP" <(E-Mail Removed)> wrote:


>Just cast it to whatever type the value of the PK is.
><Steven C> wrote in message
>news:(E-Mail Removed)...
>> 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.CurrentRowIndex]["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"

><(E-Mail Removed)> 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.CurrentRowIndex][PKName]
>> ><Steven C> wrote in message
>> >news:(E-Mail Removed)...
>> >> 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
>> >>
>> >>
>> >

>>

>


 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      6th May 2004
glad it worked!
<Steven C> wrote in message
news:(E-Mail Removed)...
> Coolness!
>
> Thanks for all your help.
>
> Steven
>
> >On Wed, 5 May 2004 18:42:46 -0400, "William Ryan eMVP"

<(E-Mail Removed)> wrote:
>
> >Just cast it to whatever type the value of the PK is.
> ><Steven C> wrote in message
> >news:(E-Mail Removed)...
> >> 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.CurrentRowIndex]["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"

> ><(E-Mail Removed)> 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.CurrentRowIndex][PKName]
> >> ><Steven C> wrote in message
> >> >news:(E-Mail Removed)...
> >> >> 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
> >> >>
> >> >>
> >> >
> >>

> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to grab current workbook filename TR Young Microsoft Excel Worksheet Functions 3 12th Jun 2009 12:41 PM
Grab 2 Values in the same row in a DataGrid in a Webform Holmsey Microsoft VB .NET 0 14th Nov 2006 10:38 PM
Query to grab records in current month only =?Utf-8?B?dHNpc29uNw==?= Microsoft Access 4 26th Jun 2006 07:33 PM
Grab current web brower control's address soundneedle@hotmail.com Microsoft Outlook Form Programming 0 11th Jun 2005 01:43 AM
Using XL to grab current user's Outlook calendar item titles, dates, and durations? KR Microsoft Excel Programming 2 22nd Nov 2004 06:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:57 PM.