Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to delete a selected record from the data grid in my application,on successful delete the selected record is still showing on the grid, how can this be removed from the grid on successfull delete and how can i show a confirmation message of the successfull delete
Posted
Comments
ZurdoDev 13-Aug-13 8:27am    
Refresh the grid. Then show a message.
Rock_Dead 13-Aug-13 8:55am    
How to do that?

again bind grid view to show the result
 
Share this answer
 
Comments
Thanks7872 13-Aug-13 8:43am    
Upvoted.
Rock_Dead 13-Aug-13 9:00am    
How to do that, this is my code

protected void gdvData_RowCommand(object sender, GridViewCommandEventArgs e)
{
InBoundDataBO obj = new InBoundDataBO();
if (e.CommandName == "Delete")
{

int index = int.Parse(e.CommandArgument.ToString());
GridViewRow row = gdvData.Rows[index];
int SUPPLIER_NUMBER =Convert.ToInt32(row.Cells[4].Text);
string message = string.Empty;
obj.DeleteSupplierDetails(SUPPLIER_NUMBER, out message);
You need to rebind the grid to the datasource.
C#
//delete row from the database
GridView1.DataSource = againRetrieveDataMethod(); //retrieve the data from the database
GridView1.DataBind();  //and then bind   
 
Share this answer
 
v2
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
MessageBox.Show("Record Deleted Successfully");


may be helpfull
 
Share this answer
 
try this..
C#
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
MessageBox.Show("Record Deleted Successfully");
 
Share this answer
 
Comments
Rock_Dead 13-Aug-13 8:58am    
This is not working
Rock_Dead 13-Aug-13 8:59am    
This is my code

protected void gdvData_RowCommand(object sender, GridViewCommandEventArgs e)
{
InBoundDataBO obj = new InBoundDataBO();
if (e.CommandName == "Delete")
{

int index = int.Parse(e.CommandArgument.ToString());
GridViewRow row = gdvData.Rows[index];
int SUPPLIER_NUMBER =Convert.ToInt32(row.Cells[4].Text);
string message = string.Empty;
obj.DeleteSupplierDetails(SUPPLIER_NUMBER, out message);

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