Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview which stores temporary data. but I want to remove row by auto generated delete button. SO how to do it, plz suggest me some solutions.
Posted
Comments
Mohan Gopi 17-Sep-13 1:20am    
Your using windows application or web application.
Shibasankar 17-Sep-13 1:31am    
Sir, I am using web application...

Hi use this link to go through the functionality for delete the data from the auto generated delete button

http://www.c-sharpcorner.com/UploadFile/9f0ae2/gridview-edit-delete-and-update-in-Asp-Net/[^]

Hope it helps you.
 
Share this answer
 
you can use some thing like this.
C#
private void btnDeleteTask_Click(object sender, EventArgs e)
        {
            DataTable newDataTable = new DataTable();
            if (dataGridView1.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow r in dataGridView1.SelectedRows)
                {
                    dataGridView1.Rows.Remove(r);
                }
                newDataTable = ((DataTable)dataGridView1.DataSource).Copy();
                dbContext.UpdateDataAdapter(newDataTable);
            }
            else
            {
                //
            }
 
Share this answer
 
Comments
Shibasankar 17-Sep-13 2:58am    
I think this is right, But I need the complete code with aspx file. Can you provide me?

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