?
Solved

SelectedItemStyle Tag in datagrid control

Posted on 2006-06-17
11
Medium Priority
?
275 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
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 2000 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

Technology Partners: 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

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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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