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

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

i'm wondering how can i get the value of primary key in datagrid.

thanks in advance
Nov 20 '05 #1
3 2492
"jaYPee" <hi******@yahoo.com> wrote in message
news:25********************************@4ax.com...
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.

Nov 20 '05 #2
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" <hi******@yahoo.com> schreef in bericht
news:25********************************@4ax.com...
i'm wondering how can i get the value of primary key in datagrid.

thanks in advance

Nov 20 '05 #3
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.


Nov 20 '05 #4

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

Similar topics

1
by: Swadh | last post by:
Hi, I need urgent help on Windows Form datagrid. I have to Display a datagrid that has a textbox column and another one combo box column. I have two tables in my Access database as: Table 1:...
3
by: Oberon | last post by:
How do I deal with this? I am getting an error for each get in the Game class (see code below). In the simplified example below I have reduced this to just 3 fields, one which can be NULL. I...
4
by: Alpha | last post by:
Hi, I've worked with C# for 5 months fixing bugs for appl. done by other programmers. I'm just writing a small C# application by myself for the first time. The database is Access 2000. I've set...
5
by: Jason | last post by:
I've been trying to figure out a good way to do this but haven't had much luck, any input would be greatly appreciated. Basically, after a datagrid is sorted, how can I get the primary key value...
3
by: Ryan Riddell | last post by:
I am using the DataGrid control from 4guys (http://aspnet.4guysfromrolla.com/demos/RowHighlighter.aspx). I want to display 2 columns and allow editing. The only column I want the user to be able to...
7
by: Dave | last post by:
Hi, Maybe I'm missing something with the DataKeyField attribute of a datagrid but it seems that it's somewhat limiting since this only allows you to specify one field as the key. I have a...
1
by: pmud | last post by:
I need an editable datagrid. But for editing a datagrid as shown in the walkthrough: Using a DataGrid Web Control to Read and Write Data, the table in the SQL database should have a primary key....
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
1
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label,textboxes and combobox are avilable to save the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.