Introduction
How to show detail page in grid view inside a row using java script.
Using the code
Unzipe the code and open files in VS2005 web application.Use sql server as database server, here I have used pubs database , author table to show authers details.
Update follwing connection string settings in web.config:
Default.aspx.cs file.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
{
String Url = "Detail.aspx?auth_id=" + GridView1.DataKeys[e.Row.RowIndex].Value;
HtmlAnchor lnkShowHideDetail = (HtmlAnchor)e.Row.FindControl("lnkSHDetail");
e.Row.Attributes.Add("Index", e.Row.RowIndex.ToString());
lnkShowHideDetail.Attributes.Add("Index", e.Row.RowIndex.ToString());
lnkShowHideDetail.Attributes.Add("mode", "HIDE");
lnkShowHideDetail.Attributes.Add("onclick", "HideShowDetails('" + GridView1.ClientID + "','" + Url + "',this,'Show Detail',' Hide Detail')");
}
}
Points of Interest
Using the above technique I have tried to open deatil page in grid view without doing postback i.e. without going throug complete page life cycle of container page ,using seperate handler to fetch details from database server and to show the results, hence try to reduce the rendered page size