Mitul Birla
Mitul Birla

Reputation: 147

About gridview events

I am using following code:

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")) + "'";

 }

so when I double click on the gridview it redirects me to next page and give error. The value of Custid it gives as follows:

Custid=System.Web.UI.WebControls.HiddenField

Upvotes: 0

Views: 45

Answers (1)

शेखर
शेखर

Reputation: 17614

you need

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

Combining the above

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

Edit 1

As Convert.ToString(e.Row.FindControl("hdfCust_Id")) output will be System.Web.UI.WebControls.HiddenField

And ((HiddenField)e.Row.FindControl("hdfCust_Id")).Value will be your required value

Upvotes: 3

Related Questions