Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone..

My problem is I have a delete button in grid view. if i click on delete button that particular row need to be deleted and some columns of that row need to be updated which on same button click.


example if i click delete that row that row needs to be deleted..that row has Status column which is active before deleting, after clicking delete that column status should change to delete, and row should be deleted and one more column that id should change to null.

What I have tried:

very confused how to do both operations on single click

help??
suggestions??
Posted
Updated 26-Feb-17 19:04pm
Comments
Karthik_Mahalingam 27-Feb-17 0:07am    
rebind the data to the gridview
Mahesh2223 27-Feb-17 0:09am    
how to do??
Karthik_Mahalingam 27-Feb-17 0:11am    
where you are getting the id
Mahesh2223 27-Feb-17 0:14am    
Yes thats what i m confused.. if i get the id also, how to do both operations on single click
Karthik_Mahalingam 27-Feb-17 0:15am    
how you are deleting a particular row?
is there a check box?

1 solution

<asp:BoundField HeaderText="ID" DataField="Id" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol" >
</asp:BoundField>

CSS
<style type="text/css">
  .hidecol
  {
    display: none;
  }
</style>


protected void btnDelete_Click(object sender, EventArgs e)
       {
           Button btn = (Button)sender;
           GridViewRow gvr = (GridViewRow)btn.NamingContainer;
           int idcolumnIndex = 5; // check this index
           string id = gvr.Cells[idcolumnIndex].Text;
       }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900