Question : How do I add an onclick action to a ButtonField inside a GridView?

I have a gridview, and in one of the columns i have inserted a Button inside a template field.  The user wants every row to have a Delete button as the last column.  What would the code look like to Delete the individual row that the Delete button was clicked on?  Thanks for the help.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:

            
                
                    
                        
                        
                    
                
                
                    
                        
                        
                    
                
                
                    
                        
                        
                    
                
                
                    
                        
                        
                    
                
                <%--  
                                            
                                                
                                                
                                            
                                        --%>
                
                    
                        
                    
                
            
        

Answer : How do I add an onclick action to a ButtonField inside a GridView?

I have handelled something like your situation like this

In the grid HTML code i have added the following line


and on the server side i have an event for GridView_RowCommand and in that i handle the event as shown
switch (e.CommandName)
{
   case "Delete":
         //Delete what you want to
         break;
}

hope this helps
Random Solutions  
 
programming4us programming4us