Click here to Skip to main content
Sign Up to vote bad
good
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 - 22:18

Comments
db7uk - 29 May '12 - 4:27
Will this not defeat the object? when you click delete, will the row not get deleted and your color with it?
sameerbhag - 29 May '12 - 4:57
i don't want to delete it
Sandeep Mewara - 29 May '12 - 5:38
web? winforms? what? So, you want to highlight a row on delete click?
sameerbhag - 29 May '12 - 8:23
exactly...for Webforms

1 solution

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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 239
1 OriginalGriff 188
2 Mahesh Bailwal 149
3 Maciej Los 140
4 Tadit Dash 128
0 Sergey Alexandrovich Kryukov 10,214
1 OriginalGriff 7,819
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 29 May 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid