Solved

SelectedItemStyle Tag in datagrid control

Posted on 2006-06-17
11
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 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