Solved

ASP.net GridView  additional column code

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

17 Experts available now in Live!

Get 1:1 Help Now