I have a grid view
,i use the row command
to open a specific window with several parameters.
Now i want to remove this button and make the whole row clickable
so if i click on the row open the same window .How to do that .
protected void gv_Details1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Confirm")
{
int index = Convert.ToInt32(e.CommandArgument);
Session["task_code"] = ((HiddenField)gv_Details1.Rows[index].Cells[0].FindControl("hf_tc")).Value;
Session["trans_serial"] = ((HiddenField)gv_Details1.Rows[index].Cells[0].FindControl("hf_ts")).Value;
MasterPage2 obj = (MasterPage2)Page.Master;
obj.SetMainVariables();
obj.PreValidate();
obj.SetDepartment();
Response.Redirect("~/Contents/" + Session["page_new"].ToString() + ".aspx", false);
}
}
Add RowDatabound event :
protected void gv_Details1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("style", "cursor:pointer;");
string abc = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
e.Row.Attributes["onClick"] = "location.href='pagename.aspx?Rumid=" + abc + "'";
}
}
Thanks :