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

Finding DataKey in GridView

i'd like to get datakey of GridView So i write code like below
but it wasn't work well. how should i do?
protected void BookGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
int tableId = int.Parse(
BookGridView.DataKeys[e.Row.DataItemIndex].ToString() );

.....

}
Nov 24 '05 #1
1 1796
Hello mike,

Once you have specified DataKeyNames, you can retrieve the datakey for the
selected row by simply using - BookGridView.SelectedValue

Cheers,
Sumeet

i'd like to get datakey of GridView So i write code like below but it
wasn't work well. how should i do?

protected void BookGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
int tableId = int.Parse(
BookGridView.DataKeys[e.Row.DataItemIndex].ToString() );
.....

}

Nov 26 '05 #2

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

Similar topics

0
by: Kivak Wolf | last post by:
Hey, I have a GridView in one web page that displays a bunch of data about companies; the DataKeyName is called "company_id". Now, when I click on a row command called "Modules" I want to copy...
0
by: mike | last post by:
how can i get datakey value of GridView ??????? protected void BookGridView_RowDataBound(object sender, GridViewRowEventArgs e) { int tableId = int.Parse( BookGridView.DataKeys.ToString() ); ...
1
by: Mark Richards | last post by:
I posted this earlier, and got no response. Basically I need to be able to grab a value from one of the fields in a gridView to populate a dropdown in another column of the gridview: I have a...
3
by: MasterChief | last post by:
I am trying to add an attribute to a gridview row so when you click on it, it will pop up an alert saying the current datakey for that row. How is it possible to get a datakey when using the...
1
by: Sean | last post by:
I have my gridview bound to a objectdatasource control and the only thing I need to hide on the grid is the primary key but I need the key in the dataset that refers to it. With a dynamic...
0
by: Stu | last post by:
Hiya, Im sure this is one of those easy if you know how type basically i have a dataview and i want to bind it to a gridview grdResults.DataSource=objDataSet.Tables.DefaultView;...
1
by: JeffBuzz | last post by:
I have searched high and low and cannot figure this out. I want programmatically select a row in my GridView based on a primary key value (DataKey). You would think this is common, but I guess not....
1
by: jc | last post by:
Duh.. How do I do this? CreditId is my datakey, but I can't seem to get to it. Dim dgItem As GridViewRow For Each dgItem In gridEmployeeCredits.Rows If dgItem.DataItem("CreditId") = 0 Then...
3
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that has a label field and a checkbox field in it. I have the checkbox set to autopost when changed. How can I get the datakey value that is assigned to that row when a checkbox...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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
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...

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.