PC Review


Reply
Thread Tools Rate Thread

how do i get the value of my primary key in datagrid?

 
 
jaYPee
Guest
Posts: n/a
 
      1st Mar 2004
i'm wondering how can i get the value of primary key in datagrid.

thanks in advance
 
Reply With Quote
 
 
 
 
Ed Bick
Guest
Posts: n/a
 
      1st Mar 2004
"jaYPee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> i'm wondering how can i get the value of primary key in datagrid.


Do you mean to have it present so that you can click on a row and retrieve
the value, but not see the pk in the grid?

If yes, you can include the column in your data set and set the width of the
column to 0.

Then, in your grids Click event, do something like this.

Dim dc As DataGridCell = MyGrid.CurrentCell 'This will be set to column 0
of the row you selected. You can change that to whatever column you like

Dim intID As Integer = MyGrid.Item(dc)



Hope that helps.



 
Reply With Quote
 
Sjaakie Helderhorst
Guest
Posts: n/a
 
      1st Mar 2004
Make the first column of you datagrid readonly and invisible:
<asp:BoundColumn Visible="False" DataField="[your uid]" ReadOnly="True"
HeaderText="uid"></asp:BoundColumn>

In your updatecommand refer to it as uid = '" & e.Item.Cells(0).Text & "'

Hope this helps.
Regards!

"jaYPee" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> i'm wondering how can i get the value of primary key in datagrid.
>
> thanks in advance



 
Reply With Quote
 
jaYPee
Guest
Posts: n/a
 
      1st Mar 2004
Thank you very much

>Do you mean to have it present so that you can click on a row and retrieve
>the value, but not see the pk in the grid?
>
>If yes, you can include the column in your data set and set the width of the
>column to 0.
>
>Then, in your grids Click event, do something like this.
>
>Dim dc As DataGridCell = MyGrid.CurrentCell 'This will be set to column 0
>of the row you selected. You can change that to whatever column you like
>
>Dim intID As Integer = MyGrid.Item(dc)
>
>
>
>Hope that helps.
>
>


 
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
Can't Make Primary Key Column Invisible in DataGrid? Joseph Geretz Microsoft Dot NET Framework Forms 6 28th Dec 2006 06:13 AM
How to identify each row in a Datagrid with no primary id? =?Utf-8?B?QWxwaGE=?= Microsoft C# .NET 4 15th Sep 2005 07:56 PM
Assoicate a primary key with a checkbox inside a datagrid Mark Microsoft ASP .NET 3 28th Apr 2005 03:47 AM
Multiple primary keys with a datagrid? =?Utf-8?B?RGF2ZQ==?= Microsoft ASP .NET 7 15th Dec 2004 05:49 PM
Primary Key in DataGrid =?Utf-8?B?UnlhbiBSaWRkZWxs?= Microsoft ASP .NET 2 30th Jul 2004 07:14 AM


Features
 

Advertising
 

Newsgroups
 


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