views:

2256

answers:

1

Hello , I want to know the best way about when we want to bind a dataTable generated based on a searchResult to a gridview ( Just for now we want to show one record ) ,

now how can we add edit-delete capability for this record shown in the gridview ? How many ways do we have for this ,

I know some but I want to reshape my knowledge , and find better ways

( the information will be bound after user clicked a button . )

+1  A: 

Instead of using a datatable you could use the SQLDataSource control which will allow you to set the different SQL commands you want to perform. By binding your gridview to this datasource you could then modify the gridview using the Edit/Update command button, modify the gridview edit templates, etc. This would provide you a fairly easy way of going about it.

If you are looking for something which gives you more control over the whole process, here is a tutorial for setting up insert/update/delete functionality to a gridview:

http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx

TheTXI
my friend , I'm not sure that I'm right or wrong , yes this could be the easiest way , but I would be glad to know if we can do such a thing when we have a dataTable based on a search result , Can we do that , Bind it to gridview or using a datasoure in between , not as the main source , thanks
Sypress
Sypress: You can bind a datatable to a gridview just by setting the Gridview's datasource equal to you datatable and calling databind. You can then manually hook into the rowcommand event that is fired when you hit you edit/update/delete button and do you DB updates in the code behind.
TheTXI
thanks man , you really helped me
Sypress