Solved

SelectedItemStyle Tag in datagrid control

Posted on 2006-06-17
11
271 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 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