Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:25:54+00:00 2026-06-02T02:25:54+00:00

How to set border for ItemTemplates in GridView? Following is the Gridview code. <div>

  • 0

How to set border for ItemTemplates in GridView?

Following is the Gridview code.

<div>
   <asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns = "false" Font-Names = "Arial" 
    Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B"  
    HeaderStyle-BackColor = "green" AllowPaging ="true"   
    OnPageIndexChanging = "OnPaging" OnRowDataBound = "RowDataBound"
    PageSize = "10" >
   <Columns>
    <asp:TemplateField>
        <HeaderTemplate>
            <asp:CheckBox ID="chkAll" runat="server" onclick = "checkAll(this);" />
        </HeaderTemplate> 
        <ItemTemplate>
            <asp:CheckBox ID="CheckBox1" runat="server" onclick = "Check_Click(this)"/>
        </ItemTemplate>
    </asp:TemplateField> 
    <asp:BoundField ItemStyle-Width = "150px" DataField = "CustomerID" HeaderText = "CustomerID" />
    <asp:BoundField ItemStyle-Width = "150px" DataField = "City" HeaderText = "City"/>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "Country" HeaderText = "Country"/>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "PostalCode" HeaderText = "PostalCode"/>
   </Columns> 
   <AlternatingRowStyle BackColor="#C2D69B"  />
</asp:GridView> 

All Bounded Fields are getting borders but not the ItemTemplated Fields.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:25:56+00:00Added an answer on June 2, 2026 at 2:25 am

    A workaround is to do this by tapping into the GridView’s RowDataBound event:

    protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
         foreach (TableCell tc in e.Row.Cells)
         {
             tc.Attributes["style"] = "border-color: #c3cecc";
         }
    }
    

    More info here: http://codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx

    See comments section for a better way…

    protected void Page_Load(object sender, EventArgs e)
    {
       this.GridView1.Attributes.Add("bordercolor", "c3cecc");
    }
    

    “With the GridView, the declarative bordercolor attribute adds an inline style declaration which only applies to the table itself, not individual cells.

    Adding the bordercolor attribute programmatically does not use an inline style, but uses the HTML bordercolor property, which browsers apply to ALL borders inside the table.”

    One more thing, if you are using Eric Meyer’s reset, it breaks the table rendering in the GridView. Solution to that particular issue is to remove all table elements from the reset rule.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following multiview set up in my aspx page: <asp:MultiView id=MultiView1 runat=server
There's this repeater... <asp:Repeater ID=myRepeater OnItemCommand=rpt1_ItemCommand runat=server OnItemDataBound=rpt1_OnItemDataBound> <HeaderTemplate> <table width=99% border=0 cellpadding=0 cellspacing=0>
I have a DIV inside my repeater as follows: <asp:Repeater ID=topicView runat=server OnItemCommand=Delete_ItemCommand> <ItemTemplate>
I designed my page with an htmlinputtext as follows <asp:TemplateField> <ItemTemplate> <asp:Label ID=lblTrialPeriodEnds runat=server
I want to set border for a div, Using: -webkit-border-radius working fine on Chrome
How do i set Border properties on a TextBox Control in Winforms so that
How can I set label's border which is dynamically generated (Not from Interface Builder)?
I've tried to set the margin and border to 0,but still not working. <style
I would like to remove border on a gtk.Button and also set its size
i have this code which include frameset. i have tried to set to this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.