0

我正在使用以下代码:

protected void gvDetails_RowCreated(object sender, GridViewRowEventArgs e)
 {
    e.Row.Attributes["ondblclick"] = "location.href='CustomerInfo.aspx?page=0&Custid=" + Convert.ToString(e.Row.FindControl("hdfCust_Id")) + "'";

 }

所以当我双击gridview时,它会将我重定向到下一页并给出错误。它给出的 Custid 值如下:

Custid=System.Web.UI.WebControls.HiddenField
4

1 回答 1

3

你需要

 ((HiddenFiled)e.Row.FindControl("hdfCust_Id")).Value

结合以上

e.Row.Attributes["ondblclick"] = "location.href='CustomerInfo.aspx?page=0&Custid=" 
      + ((HiddenField)e.Row.FindControl("hdfCust_Id")).Value + "'";

编辑 1

Convert.ToString(e.Row.FindControl("hdfCust_Id"))输出将是System.Web.UI.WebControls.HiddenField

And((HiddenField)e.Row.FindControl("hdfCust_Id")).Value将是您所需的值

于 2013-11-11T06:37:01.033 回答