Solved

ASP.net GridView  additional column code

Posted on 2011-03-23
5
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 54

Expert Comment

by:Huseyin KAHRAMAN
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

734 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