Edit/Update a single GridView field

≯℡__Kan透↙ 提交于 2019-12-24 11:35:58

问题


I've got a GridView on an ASP.NET page, on which I need to edit a single field in a row when a user clicks the 'Edit' button on that row, and have a SQL database table updated with whatever the user enters.

I'm added a CommandField to my GridView, so I now have an 'Edit' button at as the last column in each row. I'm getting the data from the database using LINQ.

My question is - how do I wire it so that when I click this 'Edit' button, the user is allowed to edit a single item in this row, then update the database with the text the user enters?

Any help is appreciated.

Thanks!


回答1:


Here are some Grid options for use with ASP.NET MVC:

grid controls for ASP.NET MVC?




回答2:


Set the fields you don't want to edit to read only:

            <asp:BoundField DataField="CustomerName" HeaderText="CustomerName" 
            ReadOnly="True" SortExpression="CustomerName" />


来源:https://stackoverflow.com/questions/5664068/edit-update-a-single-gridview-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!