This is a migrated thread and some comments may be shown as answers.

How to highlight row when button is clicked

1 Answer 462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 13 Sep 2012, 10:44 PM
I have a RadGrid that sits inside an UpdatePanel. I have the following template column defined:

                        <telerik:GridTemplateColumn UniqueName="Answers" HeaderText="Edit" DataField="Id">
                                <ItemTemplate>
                                    <asp:LinkButton OnClientClick="$(this).parent().parent().css('backgroundColor', 'cyan');" ID="btnViewAnswers" runat="server" CommandArgument='<%# Eval("Id") %>'
                                        CssClass="icolink btn_list" OnClick="btnViewAnswers_Click">Answers</asp:LinkButton>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

How do I highlight the row when clicked? I am using jQuery now to change the background color and its working, but I think the updatepanel is doing an ajax call and then the radgrid is losing the css.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Sep 2012, 04:08 AM
Hi,

Please try the following approach to give background color to a row when LinkButton in that row is clicked.

C#:
protected void btnViewAnswers_Click(object sender, EventArgs e)
{
    LinkButton btn = (LinkButton)sender;
    GridDataItem ditem = (GridDataItem)btn.NamingContainer;
    ditem.CssClass = "color";
}

CSS:
<style>
    .color
    {
        background-color:Red !important;
    }
</style>

Thanks,
Shinu.
Tags
Grid
Asked by
Alan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or