Home All Groups Group Topic Archive Search About

Finding DataKey in GridView

Author
24 Nov 2005 3:44 PM
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() );

        .....

    }

Author
26 Nov 2005 8:09 AM
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


Show quoteHide quote
> 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() );
> .....
>
> }
>

Bookmark and Share