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

Please any one can tell me
How to Delete a row from gridview which is not bounded to
datasource.

I am not used any datasource to show data in gridview
I am using a stored procedure and after i getting rows from table
i am filling to gridviewdatasource.

Now there is row in the middle of the gridview
that i want to delete.
How can i do that.

Deletecommand is not working here.
Posted
Comments
Nigam Patel 1-Jan-12 23:03pm    
when any one click on delete button then do you want to delete from database or only you want to delete from Gridview.
anushripatil 1-Jan-12 23:10pm    
u can store the gridviewdatasource in a dataset & then delete the row from that dataset. & then bind that dataset to ur gridview.

u can use item template and place a button inside gird view. store your table's primary key in button's command name property.
Ex
<asp:GridView .....>
<Columns>
....
.....
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BTdelete" runat="server" Text="Edit" CommandName='<%# Bind("EID") %>' OnCommand="BTEdit_Command"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
in cs file get command name using event and find data from table and delete it.
 
Share this answer
 
Hi Jagadeesh Bollabathini,
I think you have to set dirty flag for newly added row and then remove those row from grid view using loop.
 
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