I have a Gridview and on rowDatabound i am creating on click on that row and
showing modal popup. what i want is when the row is clicked , the ID for that row should be passed.
protected void grdOrderProduct_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ceedfc'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
e.Row.Attributes.Add("style", "cursor:pointer;");
e.Row.Attributes["onClick"] = Page.ClientScript.GetPostBackClientHyperlink(btnPop, "12");
}
}
How can i Get this “12” on my server control. i have put 12 as static for demo. but it will change.
To know which row was clicked, you have to use the
Rowproperty of theGridViewRowEventArgsRowIndex would be passed as an argument to
btnPop. In order to receive itbtnPopshould be implementingIPostBackEventHandler.Like this:
Refer ClientScriptManager.GetPostBackClientHyperlink