3
Answers

Assign Hyperlink text to a session variable

c_sharpkid

c_sharpkid

20y
10k
1
Hello everyone, I have two data bound columns in my datagrid – CategoryID and CategoryName. I have made categoryID, a hyperlink column so whenever user clicks on categoryID, it shows details of the record corresponding to that categoryID. Here is the problem - I want to assign the categoryID clicked by the user to a session variable and pass it to my webservice which in turn will pull up the data and will show it on next webpage. I don’t know which event gets fired up when hyperlink is clicked and where should I assign categoryID to a session variable ( I know you guys would think why do I need to assign categoryID to a session variable for passing it to a webservice – but believe me looking at the whole picture of the project I have to do it.) Thanks C_sharpkid
Answers (3)
0
ravikumar.b

ravikumar.b

NA 5 0 20y
Hi, I don't know it is too late. Create a link button for CategoryID to act like a hyperlink and create one more bound column to store the value of the categoryID and set it invisible(hidden). Handle the DBGrid_ItemCommand event and retrieve the value of the cell[] and store it in session. You can redirect the page to the required page while the categoryId is stored in the session. Happy programming!! -BRK.
0
c_sharpkid

c_sharpkid

NA 29 0 20y
Hello Everyone, I tried to implement the solutions you have suggested and I am getting unexpected errors. I created a linkbutton column for categoryID using the column interface of datagrid in properties. It created a button column with tag and when I changed it to tag, it gave me following error Error: tag is not defined in schema. To my surprise even if I add OnClick="lbtnCategoryIdClick" in tag it gives me an error "There is no OnClick event for Button". I am not able to figure out what am I missing while adding simple Link button in Datagrid. Please help! Thank you all. C_sharpKid
0
S_Kiryazov

S_Kiryazov

NA 145 0 20y
I don't think that Hyperlink fires any server side events. It just gets rendered into a . A way to achieve your task is to make the hyperlink to an intermediate helper page and pass the CategoryID in the URL. The intermediate page will do the communication and then redirect to the appropriate page. But my advice is to use LinkButton instead of a Hyperlink - it behaves like ordinary button, with OnCommand property etc. - just fine for your goal.