質問

I have created a Dynamic Data Entities Web Application using Scaffolding. The application is working perfectly and I am able to perform the basic CRUD operations.(This is a simple Dynamic Data Application and I have not added any custom code here, so I thought there is no need for me to put some code here. Anyhow, if you want some code here, I will do so.)
Now, I want to add in a functionality where I can select All/Some rows from the table and perform a delete on all of the selected data.
So, I would require a Select All Checkbox on the top and a Select Checkbox for each row. I also need a Delete button where I can click and perform the delete operation.
I have been searching for this but found nothing relevant. Is this even possible? Any pointers would be welcome.

役に立ちましたか?

解決

Yes of course it is possible!

You could modify the List template and/or ListDetails template in the page templates folder. In each file there is a GridView, in the ASP.net markup you could add a CheckBoxField to the Columns for the GridView. Before the GridView you could add two LinkButtons e.g. "Select All" and "Delete Selected".

The code-behind is the hard bit, I need to look at the default code again in order to give you an exact answer but I would be thinking along the lines of keeping the delete link for each row and when "Delete Selected" is clicked looping thought each row and calling delete where the CheckBox is selected. "Select All" would be a loop again or it could even be done using jQuery.

In one of my DynamicData projects I configured Global.asax to use the ListDetails template for certain tables and the List template for the rest, so you may want to create a copy of the page template and modify that instead of the original - after all it's a bit boring if most screens look the same!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top