【问题标题】:Getting event fired control cell of the grid view in Row command event在行命令事件中获取网格视图的事件触发控制单元
【发布时间】:2014-03-31 06:48:35
【问题描述】:

谁能帮我在网格视图的行命令中获取事件触发控件的单元格索引。我的网格视图中有一个单选按钮控件。如果用户单击单选按钮,我需要更改特定单元格的背景颜色。请帮我解决这个问题。我的代码如下所示。

<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>

【问题讨论】:

    标签: c# asp.net gridview rowcommand datagridviewcellstyle


    【解决方案1】:

    JQuery:

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

    CSS:

    .selectedrow
    {
    background:green;
    }
    

    有关行选择背后的代码,请参阅以下链接。

    Highlight gridview row in update panel without posting back

    【讨论】:

    • 感谢您的回答。但我需要 1. 动态地做。不在 JQuery 2 中。仅更改特定单元格。不是整行。
    • @mac,动态意味着什么?
    • @MAC,请参阅下面的链接以获取行高亮选择背后的代码http://stackoverflow.com/questions/3429576/highlight-gridview-row-in-update-panel-without-posting-back
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多