How to open Dialog page When Double Click on GridView Row in Asp.Net

How to open Dialog page When Double Click on GridView Row  in Asp.Net

Introduction : This Tutorial Explain How to Open new Dialog Page when Double Click on Gridview Row. You can need to add some Atributes to Gridview RowDataBound Event and set dialog page property Dialogwidth & DialogHieght and also you can pass the row data to new Dialoge page By the Following Implemented Code.
 Step 1:  In RowDataBound Event You can Add Dialoge Atributes as Following .

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Data.DataRowView drv = e.Row.DataItem as System.Data.DataRowView;
e.Row.Attributes.Add("ondblclick", String.Format("window.showModalDialog('Testing.aspx?name={0}', 'Testing','dialogWidth:400px;dialogHeight:400px;left:200px;top:200px' )", drv["name"]));
}
}

 In Above Code Testing.aspx is new aspx page to open new Dialog page When Double click on gridview Row You can pass row data to new page  as drv["name"]. you can also open Dialoge page inside the dialog page by adding button and set some dialog property. when you run above code you can find output same as the below.


Previous
Next Post »