Solved

SelectedItemStyle Tag in datagrid control

Posted on 2006-06-17
11
260 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Highfive Gives IT Their Time Back

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

14 Experts available now in Live!

Get 1:1 Help Now