我正在使用以下代码:
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
答案 0 :(得分: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 + "'";
Convert.ToString(e.Row.FindControl("hdfCust_Id"))
输出为System.Web.UI.WebControls.HiddenField
((HiddenField)e.Row.FindControl("hdfCust_Id")).Value
将是您所需的值