【发布时间】:2012-03-10 06:28:28
【问题描述】:
我使用以下代码和 RaisePostBackEvent 函数使 GridView 中的行可点击。
protected void gvResults_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(this, e.Row.RowIndex.ToString()));
}
}
GridView 还具有用于其中一个单元格的 DropDownList 控件。问题是单击 DropDownList 更改选择也会触发该行的 onclick。这会导致 DropDownList 的选项列表可见但无法使用,因为该行的 onclick 也已被处理。
我尝试在 DropDownList 的 onmouseover 中设置一个标志,并在 RaisePostBackEvent 函数中检查它,但这只是部分成功。这阻止了 RaisePostBackEvent 中的功能,但行 onclick 仍然发生,这意味着 DropDownList 仍处于不可用状态。
那么,当点击该行的其他部分时,如何在创建 DropDownList 功能的同时仍然允许 onclick 起作用?
注意:我目前受限于使用 .NET 2.0。
【问题讨论】: