Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using below code to delete row in datagridview but it is not deleting row till count it is lefting some row undeleted my code is

C#
AppiRow=datagridview.currentcell.rowindex;

for (int AppiLib_Count = 0; AppiLib_Count < AppiLib.Count; AppiLib_Count++)
                   {
                       dataGrid.Rows.RemoveAt(AppiRow);
                       AppiRow++;
                   }


please help on this..
Posted
Updated 4-Sep-13 19:47pm
v2

hi,

for example

you can use
HTML
OnRowDeleting="Countrylist_Rowdelete"
method of gridview

IN .cs file

C#
protected void Countrylist_Rowdelete(object sender, GridViewDeleteEventArgs e)//TO DELETE PARTICULAR RECORD SELECTED FROM GRID
       {       
           int intCode = Convert.ToInt32(Countrylist.DataKeys[e.RowIndex].Value);
           strQuery = "DELETE FROM Country_master " +
                      "WHERE CountryId=" + intCode + "";
           OpenConn();
           OleDbCommand oledbcmd = new OleDbCommand(strQuery, con);
           oledbcmd.ExecuteNonQuery();
           Display();//function that binds your gridview

       }




Hope this may help you
Happy Coding :)
 
Share this answer
 
Comments
rahuls1 5-Sep-13 1:52am    
hiplease help me through my code i am not getting your code..
Priyanka Bhagwat 5-Sep-13 2:18am    
hi can you tell me what is AppiLib.Count in your code
rahuls1 5-Sep-13 2:21am    
its count is suppose 5 it is a collection of list..
Priyanka Bhagwat 5-Sep-13 1:58am    
hi can you tell me what is AppiLib.Count in your code
Thanks7872 5-Sep-13 2:15am    
Use reply button,other wise OP won't come to know that you have commented.
 
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