Finding DataKey in GridView

M

mike

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() );

.....

}
 
T

The CynicalDoctor

Hello mike,

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

Cheers,
Sumeet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top