Solved

ASP.net GridView  additional column code

Posted on 2011-03-23
5
439 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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