473,385 Members | 1,342 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,385 software developers and data experts.

Getting the data key field value when selecting a row in a datagrid...

Stu
Hi,

I am trying to return the data key field value from a dataset when I select
a row in a datagrid after the datagrid has been bound to a dataset.

When I an the Edit, Update and Cancel row I can return the DataKey using the
sub listed below. However, the select button does not have
'DataGridCommandEventArgs' as one of it's parameters so I cannot use the
same command.

-----------
Public Sub UpdateCommand(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand
Response.Write("The datakey for this row is:" &
DataGrid1.DataKeys(e.Item.ItemIndex).ToString)
End Sub
-----------

Anybody any ideas?

Thanks in advance,

Stu

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.505 / Virus Database: 302 - Release Date: 30/07/2003
Nov 17 '05 #1
1 8859
You can get the data key value from the ItemCommand event
when a user clicks on the datagrid select button. Then
use this value to do whatever you want.
-----Original Message-----
Hi,

I am trying to return the data key field value from a dataset when I selecta row in a datagrid after the datagrid has been bound to a dataset.
When I an the Edit, Update and Cancel row I can return the DataKey using thesub listed below. However, the select button does not have
'DataGridCommandEventArgs' as one of it's parameters so I cannot use thesame command.

-----------
Public Sub UpdateCommand(ByVal sender As System.Object, ByVal e AsSystem.Web.UI.WebControls.DataGridCommandEventArg s) HandlesDataGrid1.UpdateCommand
Response.Write("The datakey for this row is:" &
DataGrid1.DataKeys(e.Item.ItemIndex).ToString)
End Sub
-----------

Anybody any ideas?

Thanks in advance,

Stu

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.505 / Virus Database: 302 - Release Date: 30/07/2003

.

Nov 17 '05 #2

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

Similar topics

12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
1
by: tshad | last post by:
Is there a way to go into the edit mode by just clicking on a field in the row of the DataGrid you want to edit? I would like to "not" show the Edit button when I show the grid. I would like to...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
1
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
5
nmm32
by: nmm32 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. I have another procedure which adds another row to the...
0
by: cms3023 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. The table inside the database has data that matches with...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.