Click in a radgrid.

2 posts, 1 answers
  1. Pierre
    Pierre avatar
    58 posts
    Member since:
    Jun 2016

    Posted 19 Aug 2016 Link to this post


    I need to click on some link in my rad grid.

    I have 2 like per row.

    on each link im using the following code till i get an answer:

         UniqueName ="LinkRpt"
         DataTextFormatString="S/N {0} "
         HeaderText="Repport link" >


    As you can see im using " Request.QueryString["var"] ".
    But i want the var to be in Session. Because this 'var' is a sensitive data.

    I know how to put things in session. Session["field1"] = "value1";

    But  i can't do that with a GridHyperLinkColum because there is no OnClick event.
    Its the same for the GridButtonColumn.
    So i guess i have to use GridTemplateColumn with a RadButtonin it.

    <telerik:GridTemplateColumn >
                Text="See Repport."
                OnClick="RadButton1_Click" >

    In this RadButton1_Click, what should i do to get the CaseID of the row clicked.

    How do i navigate to my "~/Site/mypage.aspx" ?
    if i use Javascript:

    function OnClientClicking(button, args) {
                    window.location = button.get_navigateUrl();

    with the OnClientClicking how do i set things in session ?


    Any suggestion will be appreciated.





  2. Answer
    Eyup avatar
    4046 posts

    Posted 24 Aug 2016 Link to this post

    Hello Pierre,

    Generally, you can pass the ID in query string and use it to get the rest of the data from your database in the opened web page, similar to this live sample:

    ​You can find additional samples here:

    And check the explanation provided in this post:

    In your case, however, you need to use Session, which requires abandoning the javascript QueryString approach and using server-side configuration on the code-behind. You can do that using the following steps:

    1. Use the OnClick event handler of the button.
    2. Get a reference to the GridDataItem using (sender as RadButton).NamingContainer.
    3. Use GetDataKeyValue() method to extract the record ID:

    4. Save the ID in a Session variable.
    5. Access the saved value in the new page.

    I am also sending 2 sample RadGrid web sites to demonstrate:
    1. Various ways of declaring link columns
    2. Practical implementation with Session variables.

    I hope this will prove helpful.

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top