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