asp.net - How to add Header and Subheader in Gridview -


could explain how add header , subheader in gridview shown in below picture!!enter image description here

hi can this

enter image description here

<%@ page language="c#" autoeventwireup="true"  codefile="default.aspx.cs" inherits="_default" %>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>untitled page</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:gridview id="grvmergeheader" runat="server"                        backcolor="lightgoldenrodyellow"                        bordercolor="tan" borderwidth="5px"                        cellpadding="3" forecolor="black"                        gridlines="none" borderstyle="none" cellspacing="2"                        autogeneratecolumns="false"                        datasourceid="sqldatasource1"                        onrowcreated="grvmergeheader_rowcreated">               <footerstyle backcolor="tan" />               <selectedrowstyle backcolor="darkslateblue" forecolor="ghostwhite" />               <pagerstyle backcolor="palegoldenrod" forecolor="darkslateblue"                        horizontalalign="center" />               <headerstyle backcolor="tan" font-bold="true" />               <alternatingrowstyle backcolor="palegoldenrod" />             <columns>                 <asp:boundfield datafield="departmentid"                                  headertext="departmentid"                                  sortexpression="departmentid" />                 <asp:boundfield datafield="department"                                  headertext="department"                                  sortexpression="department" />                 <asp:boundfield datafield="name"                                  headertext="name"                                  sortexpression="name" />                 <asp:boundfield datafield="location"                                  headertext="location"                                  sortexpression="location" />             </columns>         </asp:gridview>         <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:connectionstring %>"             selectcommand="select [departmentid], [department], [name], [location] [employee]">         </asp:sqldatasource>         &nbsp;</div>     </form> </body> </html> 

code behind

protected void grvmergeheader_rowcreated(object sender, gridviewroweventargs e)     {         if (e.row.rowtype == datacontrolrowtype.header)         {             gridview headergrid = (gridview)sender;             gridviewrow headergridrow = new gridviewrow(0, 0, datacontrolrowtype.header, datacontrolrowstate.insert);             tablecell headercell = new tablecell();             headercell.text = "department";             headercell.columnspan = 2;             headergridrow.cells.add(headercell);              headercell = new tablecell();             headercell.text = "employee";             headercell.columnspan = 2;             headergridrow.cells.add(headercell);              grvmergeheader.controls[0].controls.addat(0, headergridrow);          }  

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -