Introduction
How to show detail page in grid view inside a row using java script.
Screen Shot1
Screen Shot2
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
<pre />
The CodeProject team have been writing software, building communities, and hosting CodeProject.com for over 20 years. We are passionate about helping developers share knowledge, learn new skills, and connect. We believe everyone can code, and every contribution, no matter how small, helps.
The CodeProject team is currently focussing on CodeProject.AI Server, a stand-alone, self-hosted server that provides AI inferencing services on any platform for any language. Learn AI by jumping in the deep end with us:
codeproject.com/AI.