Last time, we talked about using Dreamweaver MX to establish an ASP.NET development environment, and performed functions such as data display and deletion of records in a fully visual environment.
From the perspective of implementation, all operations are entered into the DataGrid control. Some netizens said that it is like a large plug-in. I think it is quite vivid. Of course, the functions it has are not available in ordinary plug-ins. Let’s continue. Let’s talk about the categories of this control when displaying data or operating data.
Add the function of modifying the title.
The DataGrid itself has the function of modifying the record, which only needs to be set in the dialog box.
Open the default.aspx page we edited previously under Dreamweaver MX, go to the Server Behaviors window under Application, double-click the "DataGrid(DataGrid1)" control (actually it should be called server behavior in MX, haha, it's the same), Click the plus button to the right of "Columns" and select the fourth "Edit, Update, Cancel Buttons" edit button. The name is a bit long, but it does have these functions.
Set in the pop-up dialog box
Title: "Delete" - displays the title of the column;
Button Type: "Link Button" - displayed in the form of a link, you can also choose to display it in the form of a "Push Button" button;
Update Table: "dbo. Joke Table" - select the table that needs to be modified in the database
Primary Key: "Serial Number" - Primary Keyword
Submit As: "Int" - is the attribute of the serial number field, here is the numeric type
After completion, return "OK". Don't rush to close the control dialog box first. You still need to set the fields to be modified.
Double-click the "Title" column in the Columns field, and in the pop-up dialog box, set the "Read Only" selection box to unselected. For "Submit As" below, just select the data type corresponding to the title in your database. Here Is of type "NVarChar".
"OK" returns when completed, and the DataGrid control dialog box can now be confirmed. OK, save it and test this modification function.
It should now look like the picture below in the browser
Clicking on the corresponding "Edit" title bar will replace the text with a text box. Then you can modify the text in the text box and click "Update" to see the result:
That's not right, the text box is clearly filled with text, but why is it turned into "???"!
According to the reminder from netizen xpilot, it was found that this was a coding problem. After reading some ASP.NET documents, I found that you can use the ResponseEncoding attribute to request ASP.NET to use UTF-8 encoding to send web pages.
http://chs.gotdotnet.com/quickstart/aspplus/doc/cultureencoding.aspx
In the first line of the default.aspx source window, we change "gb2312" in ResponseEncoding="gb2312" to "UTF-8"
Then save and test again. As shown in the figure below, the record modification was successful.