c# - Merge Merger header columns in gridview? -


how can create below type of gridview merge merged header columns? if have example share me.

alt text

thanks in advance.

code gridview

<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> 

cs code

//row created 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);  //creating new header type          tablecell headercell = new tablecell(); //creating headercell         headercell.text = "department";         headercell.columnspan = 2;         headergridrow.cells.add(headercell);//adding headercell header.          headercell = new tablecell();         headercell.text = "employee";         headercell.columnspan = 2;         headergridrow.cells.add(headercell);          grvmergeheader.controls[0].controls.addat(0, headergridrow);     } } 

i hope work you.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -