Click here to Skip to main content
15,867,999 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to remove duplicate values from my gird row. For that am checking each row with the next row.If any match is there then it should remove that row
am using below code for removing row,
C#
Gridview1.DataSource=dt;
GridView1.DataBind();
If(//here am checking rows if any match found it will enter in to the if condition and this works fine//)
{
gridview1.DeleteRow(j);
}

here j is rowindex

But am getting error message that,
'The GridView 'Gridview1' fired event RowDeleting which wasn't handled.'


Please help.Thanks in Advance

[Edit]Code blocks added[/Edit]

Developers please please help
Posted
Updated 7-Mar-13 20:43pm
v5
Comments
Am Gayathri 8-Mar-13 2:28am    
Plz help
Am Gayathri 8-Mar-13 2:37am    
Please help me
Am Gayathri 8-Mar-13 2:43am    
Developers please please help
Jαved 8-Mar-13 2:47am    
Hi Kavitha,
is your table's primary key referenced in other table?
Am Gayathri 8-Mar-13 3:04am    
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{


}

i tried this but row is not getting deleted

Add rowdeleting event.
C#
protected void gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e)
   {
       int ID = (int)gridview1.DataKeys[e.RowIndex].Value; // primary key
 // you can write code here to delete record using ID
// use sql query to delete data
//e.g String strQuery = 'delete from table where table.id = ' + ID;
   }
 
Share this answer
 
v2
 
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