What is you datasource? You can define the datakeyname in the
properties pane of the control. Say your using sql and the field you
want to get is called "book_id", the that would be your datakeyname.
You don't even have to parse it as int, you can just add it right into
the query string , or better yet, you can set the datanavigate binding
to book_id, then set the navigate field to blah.aspx?bid={0}
Need more help, let me know brother
On Dec 31, 2008, at 1:25 PM, "m...@ni" <[email protected]> wrote:
Suppose that there is a Datalist control, and in that control there
are further three controls, first is
label(to show title of Book), second is image(to show the picture of
that book) while the third control is a linkbutton(when this button is
clicked, it basically redirects the current page to BookDetail.aspx).
this third control basically get the DataKey of that record and then
redirect itself to BookDetail.aspx along with the BookId as a
QueryString, now the things is that, how come, i get the DataKey of
that record, from where the button is clicked, as the datalist
contains 10 records, which indirectly means that there are 10 DataKeys
present (1 for each record).
Protected Void LnkBtn_Click(----,----)
{
//here I just want to get the DataKey of that record, for which
the user wants to see more
//detail by clicking 1 book out 10 books (that are displayed in
datalist)
Int Bid=int.parse(DataList1.DataKeys[0].ToString()); // I new it
is wrong to get current DataKey
Response.Redirect(~/BookDetail.aspx?BId=”+BId);
}