简体   繁体   中英

How to show and Edit (CRUD) datatable in view MVC.4, C#

I am having an object of DataTable which is created by reading some short of files in Controller. I want to show a dynamic table (data depends, data present in files or not or it may a have column or not) In View using j-query action call after a dropdown selection changed.

also I want a specific column to be in editable mode so I can edit the value and same should be reflected in file after update .

Please suggest me the approach , I have done with data fetch but unable to show in UI and Unable to Edit it ,

Create a partial view with a model containing two lists

ITable
{
    IList<IColumn> Columns;
    IList<IRow> Rows
}

Create view for this model, either use loop or display template to render the values of table.

  1. Edit Row

With each row provide a hyper-link to edit/delete the row, and let scaffolding create action/view for edit page by using model IRow .

  1. Edit Column

Create a partial view containing textbox and saving functionality(button etc.), with the column identifier ( figure it out yourself ), and onclick display this partial view over the label.

And on click of save button post server with the value and ID to your action, hide the partial view contents from page, update label or refresh the page. (handle errors as per your project)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM