突出显示更新面板的GridView行不回发不回、面板、突出、GridView

2023-09-03 05:51:44 作者:Breaking

我有一个更新面板具有以下code一个GridView选择行,这反过来又更新的UpdatePanel从形式记录的细节。

I have a gridview in an update panel with the following code to select a row, this in turn updates another updatepanel with details from the form record.

protected void gvMainGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //Make the entire row clickable to select this record
            //Uses javascript to post page back
            e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
            e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
            e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(this.gvMainGrid, "Select$" + e.Row.RowIndex));   

        }
    }

我是手动绑定从数据库的GridView和不想重新绑定网格只是为了突出显示该行,但我似乎无法任何JavaScript添加到onclick事件,似乎要么显示GetPostBackClientHyperlink或该行突出显示的JavaScript。

I am manually binding the gridview from a database and don't want to rebind the grid just to highlight the row, but I can't seem to add any javascript to the onclick event, it seems to either show the GetPostBackClientHyperlink or the row highlight javascript.

推荐答案

我挣扎着上单击添加事件既行数据绑定:

I was struggling to add both on click events to the row databound:

e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(this.gvMainGrid, "Select$" + e.Row.RowIndex));   

e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + e.Row.RowIndex.ToString() + "')");

追加回发行的亮点方法后选择;似乎已经奏效。

Appending the PostBack select after the row highlight method with ';' seems to have worked.

e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + e.Row.RowIndex.ToString() + "');" + ClientScript.GetPostBackClientHyperlink(this.gvMainGrid, "Select$" + e.Row.RowIndex));