0

Can anybody please help me to get the cell index of the event fired control in row command of the grid view. I have one radio button control in side my grid view. If the user clicks on the radio button, i need to change the background color of the particular cell. Please help me to resolve this. My code is showing below.

<asp:TemplateField HeaderText="MD-R">
                    <ItemTemplate>
                        <asp:ImageButton ID="imgMDR" runat="server" ImageUrl="" ToolTip='<%# Eval("MDR") %>'
                            CommandName="MDR" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'
                            OnClientClick="javascript:return ConfirmReport(this);" />
                    </ItemTemplate>
                </asp:TemplateField>

1 Answers1

0

JQuery:

function ConfirmReport(obj) {
   $("tr").removeClass("selectedrow");
   $(obj).closest('tr').addClass("selectedrow");
 }

CSS:

.selectedrow
{
background:green;
}

For code behind row selection, refer the below link.

Highlight gridview row in update panel without posting back

Community
  • 1
  • 1
RGS
  • 5,131
  • 6
  • 37
  • 65
  • Thanks for your answer. But I need 1. to do dynamically. Not in JQuery 2. to change the particular cell only. Not the entire Row. –  Mar 31 '14 at 06:55
  • @mac, dynamically means? – RGS Mar 31 '14 at 06:56
  • @MAC, Please refer the below link for code behind row highlight selectionhttp://stackoverflow.com/questions/3429576/highlight-gridview-row-in-update-panel-without-posting-back – RGS Mar 31 '14 at 07:12