Solved

ASP.net GridView  additional column code

Posted on 2011-03-23
5
437 Views
Last Modified: 2012-06-21
Hi

I want to add an additional column in my GridView in ASP.net and I was given the following code and told to put it in between the <Columns> tag but as you can see in my GridView there is no such tag in my code in the code section. Can someone please show me where to insert this code to add a new column. I need the new column to ne a Yes/No column that people can tick


 <asp:TemplateField>
  <ItemTemplate>
    <asp:CheckBox ID="chkSelected" runat="server" />
  </ItemTemplate>
</asp:TemplateField>

<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
            GridLines="None">

            <AlternatingRowStyle BackColor="White" />
            <EditRowStyle BackColor="#7C6F57" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#E3EAEB" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F8FAFA" />
            <SortedAscendingHeaderStyle BackColor="#246B61" />
            <SortedDescendingCellStyle BackColor="#D4DFE1" />
            <SortedDescendingHeaderStyle BackColor="#15524A" />
        </asp:GridView>

Open in new window

0
Comment
Question by:murbro
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35200567
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"  
            GridLines="None"> 
            <Columns>

            </Columns>
            <AlternatingRowStyle BackColor="White" /> 
            <EditRowStyle BackColor="#7C6F57" /> 
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> 
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> 
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> 
            <RowStyle BackColor="#E3EAEB" /> 
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> 
            <SortedAscendingCellStyle BackColor="#F8FAFA" /> 
            <SortedAscendingHeaderStyle BackColor="#246B61" /> 
            <SortedDescendingCellStyle BackColor="#D4DFE1" /> 
            <SortedDescendingHeaderStyle BackColor="#15524A" /> 
        </asp:GridView>

Open in new window

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 35200598
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 35200607
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"   
            GridLines="None">  
            <Columns> 
                <asp:TemplateField>
                   <ItemTemplate>
                       <asp:CheckBox ID="chkSelected" runat="server" />
                  </ItemTemplate>
               </asp:TemplateField> 
            </Columns> 
            <AlternatingRowStyle BackColor="White" />  
            <EditRowStyle BackColor="#7C6F57" />  
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />  
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />  
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />  
            <RowStyle BackColor="#E3EAEB" />  
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />  
            <SortedAscendingCellStyle BackColor="#F8FAFA" />  
            <SortedAscendingHeaderStyle BackColor="#246B61" />  
            <SortedDescendingCellStyle BackColor="#D4DFE1" />  
            <SortedDescendingHeaderStyle BackColor="#15524A" />  
        </asp:GridView> 

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 35201056
Great answer. Thanks very much :)
0
 

Author Comment

by:murbro
ID: 35201136
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now