Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I am making an asp.net webform page .... so far i have generated my gridview from datatable and datarow ! , i have also put a delete btn which is actually a asp:commandfield ... available in gridview settings .... now that i want is that when a user clicks that DELETE BUTTON, that current row gets deleted !! so far i have not implemented SQL Database or SQL DATA TABLES .... please help me out ..... for more detailed info please open this link i have attached that image .....

Link :
https://drive.google.com/file/d/0B8NFUJX6CxVzeVR0SnFkcG9TNDg/edit?usp=sharing[^]
Posted
Comments
Krunal Rohit 18-Mar-14 10:51am    
It looks like you don't want to make any change after you make any change in gridview, right ??

-KR
Emad Hassan Khan 18-Mar-14 10:59am    
yes
only that current row which i want to delete will be deleted , and it will not effect other rows

On Delete Event
GridView1.DeleteRow(GridView1.SelectedIndex);
 
Share this answer
 
v2
Comments
Emad Hassan Khan 18-Mar-14 11:20am    
that didn't work .... i have a DataField="AssignID" also used in gridview

protected void AssignmentGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
AssignmentGrid.DeleteRow(AssignmentGrid.SelectedIndex);

}
Jawad Ahmed Tanoli 18-Mar-14 11:34am    
is there any error ? or exception
Jawad Ahmed Tanoli 18-Mar-14 11:39am    
post your code how you bind gridview is it in page load event have you put !postback
Jawad Ahmed Tanoli 18-Mar-14 11:43am    
try this
AssignmentGrid.Rows[AssignmentGrid.SelectedIndex].visible=false;
Emad Hassan Khan 19-Mar-14 3:08am    
jawaad follow my coding in this page bottom ..
First get all the data in some collection, let's say, in a List<t></t>.

Assign this List as a DataSource to the Gridview.

And perform the operations like, INSERT-UPDATE-DELETE on this List<t> and then again bind it to the Gridview.

I don't have any working example, so I can't explain it through it. But yeah, I have done this a while ago, and worked properly.

Remember, all you have to do is, play around the List<t> rather than Database :)

-KR
 
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