How to make cells editable and convenient for users to use by GridView controls in Asp.net
This article mainly introduces the Asp.net GridView control how to achieve cell editable and convenient for users to use, the article is very detailed, has a certain reference value, interested friends must read it!
Recently do a function, taking into account the convenience of users, reduce the number of pop-up pages, use the "Edit" button without popping up the page directly to edit the contents of the current row of cells. The entry page is displayed as follows:
Click the "Edit" button and display as follows:
Both "week" and "whether to go to work" numbered 1 can be edited. After editing, click "Update" to save.
The data loading in the first figure is achieved by the following methods:
Protectedvoid GridView_RowDataBound (object sender, GridViewRowEventArgs e)
{. }
The modified data in the second figure is achieved in the following ways:
ProtectedvoidGridView_Pue_RowUpdating (object sender, GridViewUpdateEventArgs e)
{. }
I thought it could be done in this way, but who knew there was a "fire unhandled event RowEditing" error on the update button:
Added to GridView
ProtectedvoidGridView_RowEditing (object sender, GridViewEditEventArgs e)
{. }
Solve this problem, but you need to click the Edit button twice each time to see the interface shown in figure 2. The first time you debug the edit button, you jump into the GridView_RowEditing method and add code to it:
GridView.EditIndex= e.NewEditIndex
BindGrid ()
Solve the problem
The above is all the contents of the article "how to make the GridView control in Asp.net editable and easy for users to use". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!