RowSelected back color on Hyperlink click inside radGrid columns

2 posts, 0 answers
  1. Robert
    Robert avatar
    6 posts
    Member since:
    Jan 2012

    Posted 23 Feb 2012 Link to this post

    Row is not selected (background color) when i click on  Hyperlink inside a radGrid row.
    pls refer to the sample code how i declared the Hyperlink inside RadGrid Columns.
    I'm not using any <EditItemStyle....>

    Lets say,
    I have 5 rows in a RadGrid with a hyperlink in one column .
    >i clicked on Row2 (not on the Hyper link) ...Row2 is Highlighted with default backcolor.
    > now if i click on Hyperlink in Row3, the selected Row is still the Row2 with the highlighted backcolor.

    So pls help me in fixing this.
                <telerik:GridTemplateColumn AllowFiltering="false" Display="true" UniqueName="Edit" >                    
                                        <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server" >                           
                                                <a  href="<%= test %>" >
                                                     <img id="imgEdit" align="middle" style="border:0" alt="" src="edit.gif" />
                         <HeaderStyle Width="30px" />
                          <ItemStyle HorizontalAlign="Left" />                       
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Oct 2012 Link to this post

    Hi Robert,

    I guess you are using GridHyperLinkColumn inside the RadGrid. Please check the following code snippet I tried to select a row on HyperLinkColumn click.

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridDataItem)
            GridDataItem item1 = (GridDataItem)e.Item;
            HyperLink hyplnk = (HyperLink)item1["UniqueName"].Controls[0];
            hyplnk.Attributes.Add("OnClick", "return Click('" + item1.ItemIndex + "');");

    <script type="text/javascript">  
        function Click(indx)
            var RadGrid2 = $find("<%= RadGrid1.ClientID %>");
             var gridSelectedItems = RadGrid2.get_masterTableView().get_selectedItems();
             for (var i = 0; i < gridSelectedItems.length; i++) {
                 if (gridSelectedItems[i].get_selected()) {

Back to Top