Solved

SelectedItemStyle Tag in datagrid control

Posted on 2006-06-17
11
272 Views
Last Modified: 2012-08-13
Hi, I am trying to set bordercolor property as black like the following but it does not work

<SelectedItemStyle BorderColor="Black" BackColor="#C6D6EF"></SelectedItemStyle>

Do someone have any idea why bordercolor property fails?!
0
Comment
Question by:Abdu_Allah
  • 6
  • 5
11 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16928801
this works for me

<asp:GridView ID="GridView1" runat="server" >
            <RowStyle CssClass="GridView1" />
            <SelectedRowStyle BorderColor="Black" BackColor="#C6D6EF" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
            </Columns>
        </asp:GridView>

if you remove the selecteditem style and just click the select what happens?
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16928810
this also work fine

        <asp:DataGrid ID="DataGrid1" runat="server">
        <SelectedItemStyle BorderColor="Black" BackColor="#C6D6EF"></SelectedItemStyle>

            <Columns>
                <asp:ButtonColumn CommandName="Select" Text="Select"></asp:ButtonColumn>
            </Columns>
        </asp:DataGrid>

when are you binding the grid?
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16929058
The BackColor property works fine but BorderColor fails. Do BorderColor works fine for you?!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16929061
I bind it in Page_load
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16930951
try this

    protected void DataGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataGrid dg = (DataGrid)sender;

        DataGridItem dgr = dg.SelectedItem;

        foreach (TableCell cell in dgr.Cells)
        {
            cell.BackColor = System.Drawing.Color.DarkGray;
            cell.BorderStyle = BorderStyle.Solid;
            cell.BorderWidth = 3;
            cell.BorderColor = System.Drawing.Color.Blue;
        }
    }
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16932804
I use VB language!
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16934195
I convert it an it is working fine now but please one more thing what if I want to put a color for example: #C6D6EF instead of System.Drawing.Color.Blue

Points increased to 400
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16934211
Something else I want to color the border of entire row and not border of each cell.
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16939429
sorry I cant help it that you use vb :)

 cell.Style["border-bottom-color"] = "#C6D6EF";

i am looking into just this is a bit harder - here is a good link on some other stuff on fomratting that looks cool
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndive/html/data01102002.asp
0
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 500 total points
ID: 16939530
try

        DataGrid dg = (DataGrid)sender;

        DataGridItem dgr = dg.SelectedItem;

        foreach (TableCell cell in dgr.Cells)
        {
            cell.Style["background-color"] = "AliceBlue";
            cell.BorderStyle = BorderStyle.Solid;
            cell.BorderWidth = 3;
            //cell.Style["padding"] = "0px";
            cell.Style["border-color"] = "#C6D6EF";
            cell.Style["border-right-width"] = "0px";
            cell.Style["border-left-width"] = "0px";


        }
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16942798
That is great it works fine, thank you man.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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