In DataGrid OnClick Event i want to show Some color

Discussion in 'ASP .Net' started by karunakar, Jan 25, 2005.

  1. karunakar

    karunakar Guest

    Hi All

    In datagrid OnMouseOver iam showing some color
    Onmouseout also working fine .
    Here my problem is when ever click the pariculat row in DataGrid iam showing
    red color that time i am not getting any problem .
    when ever mouse was changed paricular row that time color is lossed
    "When ever click the particular Row That time i want to show that color &
    that time dont loss that color( when ever onMouseover changed)"
    Here it's not happening
    Here i am using this code "Onclick event " it is showing that color but it
    is not stable that color :
    e.Item.Attributes.Add("onclick","this.style.backgroundColor='Red';
    this.style.cursor='hand';");

    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver';
    this.style.cursor='hand';");

    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='yellow';
    this.style.cursor='hand';");


    Regards,
    Karunakara Rao.
    karunakar, Jan 25, 2005
    #1
    1. Advertising

  2. karunakar

    David Jessee Guest

    instead of setting the background color, use style defined in your style
    sheet. This makes it so you can change the formatting without recompiling.
    Also, this means you can...

    <style>
    ..hoverStyle {background-color: silver; cursor:hand}
    ..regularStyle {background-color: yellow; cursor:hand}
    ..clickedStyle (background-color: red; cursor:hand}
    </style>
    ....and in your code...

    e.Item.Attributes.Add("onclick","this.className='clickedStyle';");

    e.Item.Attributes.Add("onmouseover",
    "if(this.className!='clickedStyle')this.className='hoverStyle';");


    e.Item.Attributes.Add("onmouseout","if(this.className!='clickedStyle')this.c
    lassName='regularStyle';")

    .....and be sure to add, for default state...
    e.Item.Attributes.Add("class","regularStyle")

    "karunakar" <> wrote in message
    news:...
    > Hi All
    >
    > In datagrid OnMouseOver iam showing some color
    > Onmouseout also working fine .
    > Here my problem is when ever click the pariculat row in DataGrid iam

    showing
    > red color that time i am not getting any problem .
    > when ever mouse was changed paricular row that time color is lossed
    > "When ever click the particular Row That time i want to show that color &
    > that time dont loss that color( when ever onMouseover changed)"
    > Here it's not happening
    > Here i am using this code "Onclick event " it is showing that color but it
    > is not stable that color :
    > e.Item.Attributes.Add("onclick","this.style.backgroundColor='Red';
    > this.style.cursor='hand';");
    >
    > e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver';
    > this.style.cursor='hand';");
    >
    > e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='yellow';
    > this.style.cursor='hand';");
    >
    >
    > Regards,
    > Karunakara Rao.
    >
    >
    >
    >
    >
    >
    >
    David Jessee, Jan 25, 2005
    #2
    1. Advertising

  3. karunakar

    karunakar Guest

    Thank u it's working fine

    Here what ever select in datagrid row that can be deselect the row (when
    ever click another row that is not happend in my DataGrid.)
    I want deselect the partcular row

    Regards
    Karunakara Rao

    "David Jessee" <> wrote in message
    news:%...
    > instead of setting the background color, use style defined in your style
    > sheet. This makes it so you can change the formatting without

    recompiling.
    > Also, this means you can...
    >
    > <style>
    > .hoverStyle {background-color: silver; cursor:hand}
    > .regularStyle {background-color: yellow; cursor:hand}
    > .clickedStyle (background-color: red; cursor:hand}
    > </style>
    > ...and in your code...
    >
    > e.Item.Attributes.Add("onclick","this.className='clickedStyle';");
    >
    > e.Item.Attributes.Add("onmouseover",
    > "if(this.className!='clickedStyle')this.className='hoverStyle';");
    >
    >
    >

    e.Item.Attributes.Add("onmouseout","if(this.className!='clickedStyle')this.c
    > lassName='regularStyle';")
    >
    > ....and be sure to add, for default state...
    > e.Item.Attributes.Add("class","regularStyle")
    >
    > "karunakar" <> wrote in message
    > news:...
    > > Hi All
    > >
    > > In datagrid OnMouseOver iam showing some color
    > > Onmouseout also working fine .
    > > Here my problem is when ever click the pariculat row in DataGrid iam

    > showing
    > > red color that time i am not getting any problem .
    > > when ever mouse was changed paricular row that time color is lossed
    > > "When ever click the particular Row That time i want to show that color

    &
    > > that time dont loss that color( when ever onMouseover changed)"
    > > Here it's not happening
    > > Here i am using this code "Onclick event " it is showing that color but

    it
    > > is not stable that color :
    > > e.Item.Attributes.Add("onclick","this.style.backgroundColor='Red';
    > > this.style.cursor='hand';");
    > >
    > > e.Item.Attributes.Add("onmouseover",

    "this.style.backgroundColor='Silver';
    > > this.style.cursor='hand';");
    > >
    > > e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='yellow';
    > > this.style.cursor='hand';");
    > >
    > >
    > > Regards,
    > > Karunakara Rao.
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
    karunakar, Jan 25, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Cobban
    Replies:
    9
    Views:
    402
    Roedy Green
    Apr 18, 2004
  2. Richard Thoms
    Replies:
    6
    Views:
    4,909
    Richard Thoms
    Dec 2, 2005
  3. Kamaljeet Saini
    Replies:
    0
    Views:
    378
    Kamaljeet Saini
    Feb 13, 2009
  4. Matt
    Replies:
    5
    Views:
    178
    Michael Winter
    Feb 12, 2004
  5. Todd Cary

    OnClick event handler to show PDF file?

    Todd Cary, May 13, 2004, in forum: Javascript
    Replies:
    2
    Views:
    197
    Todd Cary
    May 13, 2004
Loading...

Share This Page