Solved

removing headertext from a gridview

Posted on 2011-03-09
3
729 Views
Last Modified: 2013-11-07
I have a gridview I want the header to not show (th row)  

This is what I have coded.

  <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                DataSourceID="eventTeamHotelNames" >
                <Columns>
                             </asp:TemplateField>
                    <asp:TemplateField >
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("name") %>' CssClass="labelHotel2"></asp:Label>
                        </ItemTemplate>
                        <ControlStyle CssClass="labelHotel2" />
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

This is what the browser shows.

<table cellspacing="0" rules="all" border="1" id="ctl00_ctl00_topbody_GridView2" style="border-collapse:collapse;">
            <tr>
                  <th scope="col">&nbsp;</th>
            </tr><tr>
                  <td>
                            <span id="ctl00_ctl00_topbody_GridView2_ctl02_Label1" class="label2" style="font-family:Arial,Helvetica;">Princeton</span>
                        </td>

            </tr>
      </table>
0
Comment
Question by:kw66722
3 Comments
 
LVL 10

Assisted Solution

by:hosneylk
hosneylk earned 200 total points
Comment Utility
0
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 300 total points
Comment Utility
Code:

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                DataSourceID="eventTeamHotelNames"  ShowHeader="false" > Add this
                <Columns>
                            </asp:TemplateField> Remove this
                    <asp:TemplateField >
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("name") %>' CssClass="labelHotel2"></asp:Label>
                        </ItemTemplate>
                        <ControlStyle CssClass="labelHotel2" />
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

This is what the browser shows.

<table cellspacing="0" rules="all" border="1" id="ctl00_ctl00_topbody_GridView2" style="border-collapse:collapse;">
            <tr>
                  <th scope="col">&nbsp;</th>
            </tr><tr>
                  <td>
                            <span id="ctl00_ctl00_topbody_GridView2_ctl02_Label1" class="label2" style="font-family:Arial,Helvetica;">Princeton</span>
                        </td>

            </tr>
      </table>
0
 
LVL 1

Author Comment

by:kw66722
Comment Utility
I am trying to close this accepting multiple solutions and when I click the multiple button it does not let me check of another one. It only takes the answer from the solution that I click accept multiple.  Any suggestions how I can do that?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

771 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

16 Experts available now in Live!

Get 1:1 Help Now