Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Gridview with 8 columns in that 3 are belong to one group and another 3 are belongs to another group 2 are individual
i need another row in the gridview header how to do that and how to make another header

download my Source File From below link
and suggest me
how to do that

http://www.mediafire.com/?50a6q8gmi7r7twg[^]
Posted

Hi,

I tried some line of code so you can try this.

ASP.NET
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
            <columns>
                <asp:templatefield>
                    <HeaderTemplate>
                        <table width="100%" align="center">
                            <tr>
                                <td colspan="3">
                                    Sales Department
                                </td>
                                <td colspan="3">
                                    Account Department
                                </td>
                                <td colspan="2">
                                    Non-Tech
                                </td>
                            </tr>
     <tr>
                              <td>Manager Sales</td>
                              <td>Executive Sales</td>
                              <td>Sales man Sales</td>
                              <td>Main Acc</td>
                              <td>Sal Acc</td>
                              <td>Individual Acc</td>
                              <td>working Days</td>
                              <td>Leaves</td>
                            </tr>
                    </HeaderTemplate>
                    <itemtemplate>
                        <tr>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                            <td>
                                <%#Eval("values") %>
                            </td>
                        </tr>
                    </itemtemplate>
                    <footertemplate>
</footertemplate></table>
                        
                    
                
            </columns>


I hope it can helps you too.

All the best
 
Share this answer
 
v3
Comments
krishna_goluguri 20-Sep-11 4:41am    
please download my code and see and suggest i searched lot in the net but failed to find a good solution all are contains errors in atleast one situation
Muralikrishna8811 20-Sep-11 4:43am    
Sry I'm unable to see your code.

Try this it can works for you
Muralikrishna8811 20-Sep-11 4:45am    
here you c in my code as your requirement you can get two rows in your header
with three are one group and ...as your wish.

and one more thing is </table> must be in between footer template tag
krishna_goluguri 20-Sep-11 4:45am    
your code not works it simply creates another columns
krishna_goluguri 20-Sep-11 4:47am    
i given a link click on that you get my code
Hi,

Here 'm providing clear code for it check once.

In design page you'll have following code
ASP.NET
<asp:datalist id="DataList1" runat="server" widht="70%">
  <HeaderTemplate >
    <table width="100%" align="center" border="1">
       <tr>
         <td colspan="2">fgdfgdfg</td>

         <td colspan="2">dfgdfgdfg</td>

         <td>dfgdfg</td>
       </tr>
           <tr>
         <td>gfdg</td>
         <td>gdfgdf</td>
         <td>fgfdg</td>
         <td>fdg</td>
         <td>dgdfgdf</td>
       </tr>
  </HeaderTemplate>
  <itemtemplate>
        <tr>
         <td>dfgfdg</td>
         <td>gfd</td>
         <td>gdfg</td>
         <td>fdgfd</td>
         <td>gdfgfdd</td>
       </tr>
  </itemtemplate>
  <footertemplate>
      </footertemplate></table>


In code behind file the following code'll be paste in page load method

C#
       List<string> str = new List<string>();
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        str.Add("sdgfsdfsd");
        DataList1.DataSource = str;
        DataList1.DataBind();
</string></string>


Now see My code is right or wrong


All the best
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900