Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Color DataGrid delete
Hi
 
I am having a DataGrid and need to change the color of the row in datagrid on clicking the Delete LinkButton in Datagrid.
 
Please help.
 
ThanKs.
Posted 28-May-12 23:18pm
Comments
db7uk at 29-May-12 4:27am
   
Will this not defeat the object? when you click delete, will the row not get deleted and your color with it?
sameerbhag at 29-May-12 4:57am
   
i don't want to delete it
Sandeep Mewara at 29-May-12 5:38am
   
web? winforms? what?
 
So, you want to highlight a row on delete click?
sameerbhag at 29-May-12 8:23am
   
exactly...for Webforms

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can do the following by Injecting Javascript function on onClick of link button for a grid row.
 
For injecting JS, you need to use RowDataBound of GridView, something like:
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{ 
   DataControlRowType rtype = e.Row.RowType;  
   if (rtype == DataControlRowType.DataRow && rtype != DataControlRowType.Footer
       && rtype != DataControlRowType.Separator && rtype != DataControlRowType.Header
       && rtype != DataControlRowType.Pager)  
   { 
      // Highligh row on click of row
      e.Row.Attributes.Add("onclick", "Highlight(this);");
   }
}
Modify it for any event like mouseover or link button click, etc.
Try!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100