Click here to Skip to main content
15,915,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends


I have gridview which I am dynamically creating and Passing Its into Excel on button click...

Using ItemBound(Like Rowbound) event I am setting particular cell Border Style into None... actally I need to Remove the Border of particular cells Left,Top and Bottom part I dont want to remove the Border on Right side Is there any way to do this?

Please give me some Tips.......
Posted

Well, the rowstyle defines the style for the tr but I need to style the td. I know how do specify the class for the td but I have to do it for everty node in columns.

I was able to solve this issue in my css file. I first specified a css class for RowStyle and AlternatingRowStyle. Then in the css I created a new style like this
CSS
.GridViewRowStyle td, .GridViewAlternatingRowStyle td
{
    /* style for the td*/
}


The reason I wanted to this was because the way asp.net renders the GridView, it does not look the same in all browsers. So I wanted to skin it using pure css so it would look the same in all browsers and now it does. Below is the css code and the skin code that I used if anyone else is having this issue.
CSS
.GridViewStyle
{
    border-right: 2px solid #A7A6AA;
    border-bottom: 2px solid #A7A6AA;
    border-left: 2px solid white;
    border-top: 2px solid white;
    padding: 4px;
}

.GridViewStyle a
{
    color: #FFFFFF;
}

.GridViewHeaderStyle th
{
    border-left: 1px solid #EBE9ED;
    border-right: 1px solid #EBE9ED;
}

.GridViewHeaderStyle
{
    background-color: #5D7B9D;
    font-weight: bold;
    color: White;
}

.GridViewFooterStyle
{
    background-color: #5D7B9D;
    font-weight: bold;
    color: White;
}

.GridViewRowStyle
{
    background-color: #F7F6F3;
    color: #333333;
}

.GridViewAlternatingRowStyle
{
    background-color: #FFFFFF;
    color: #284775;
}

.GridViewRowStyle td, .GridViewAlternatingRowStyle td
{
    border: 1px solid #EBE9ED;
}

.GridViewSelectedRowStyle
{
    background-color: #E2DED6;
    font-weight: bold;
    color: #333333;
}

.GridViewPagerStyle
{
    background-color: #284775;
    color: #FFFFFF;
}

.GridViewPagerStyle table /* to center the paging links*/
{
    margin: 0 auto 0 auto;
}

Skin file:
ASP.NET
<asp:GridView CssClass="GridViewStyle" runat="server" >
    <FooterStyle CssClass="GridViewFooterStyle" />
    <RowStyle CssClass="GridViewRowStyle" />
    <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
    <PagerStyle CssClass="GridViewPagerStyle" />
    <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
    <HeaderStyle CssClass="GridViewHeaderStyle" />
</asp:GridView>
 
Share this answer
 
Comments
Tony Tom.k 16-Apr-12 8:40am    
In my code I am creating gridview in page_load only. In Aspx page not using the skin file,
Is there any way to call cssclass in aspx.cs code section
In Item_bound event we can give styles to particular cells in this way

C#
e.Item.Cells[1].Style.Add("border-right-color","black");
e.Item.Cells[1].Style.Add("border-top-color", "white");
e.Item.Cells[1].Style.Add("border-bottom-color", "white");



or we can call css class inside aspx.cs page
in this way

e.Item.CssClass = "GridViewStyle";


but css class is not working for me but using first method I fix my problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900