6. Found a record to revise a page
Relevant introducing (attention: To can display code, all code are in under " < " later and " > " before added blank space, discomfort is excused more please! ) :
Logarithm occupies add, revise, delete 3 be pair of databases main operations. This section introduction revises record share.
STEP 1 designs modification circuit
Generally speaking, need to undertake updating to designation record only, so need builds search page to undertake inquiring, show inquiry as a result in result page, let an user undertake modification to its. Replace the job through referring an operation to finish finally.
Above all, build inquiry page. In the procedure that establishs Dataset, we can pass data filter Filter to choose requires data. Because we will click the catenary fetch in DataList to arrive at this page, choose URL Parameter so and use key word CODE to choose nee ds page.
[Graph 6-1 chooses data]
For this, modify.aspx file is built in the site, add plan of DataSet as above.
Step2 builds detail page
To produce a link, should build navigation page above all. Can be opposite in the 3rd DataGrid that builds in the section the page is revised achieve such navigation result. The form of DataGrid is revised, data can install the character that has a link to show likewise. Also can realize same function in DataList and Repeater likewise, it is to install a super catenary to receive detail page.
Open original Location2.aspx document, revise former DataList type. Choice DataListm clicks Edit Columns(to be like graph 6-2) . Playing the DataGrid form that give to design a dialog box (in graph 6-3) , can be the type setting of Location_name Hyperlink. Pitch on Location_name, click pushbutton of Change Column Type to change for Hyperlink.
[Graph 6-2 Edit Columns. . ..
[Graph 6-3 installs Hyperlink]
Set following plans to Hyperlink,
[Graph 6-4 setting links key word]
Indication data region Location_name, join key word is Code, need jumps the page that turns is Modify.aspx page. The specific network address link after clicking a link will is
Http://yoursite/modify.aspx? The value of the Code of the record that CODE= place clicks
And the record that the value of the Code that Modify.aspx page also will come to through passing inquires to place needs from inside the database.
To data is updated in Modify.aspx page, use watch sheet with respect to need. This binds data logging and input casing with respect to need calm. Similar in the kind that calm data ties in Dreamweaver MX and Dreamweaver UltraDev. the page the setting is like graph 6-5. Build 6 Text Field, a HiddenField, pushbutton of a Submit, put proper place. Among them HiddernField is worth with the CODE that records at saving this. Because Code value is key word, do not want a change so.
[Page of graph 6-5 Modify.aspx]
Click Binding label, will specific data procrastinate to it corresponding Text Field. Can set the indication kind of data in Format at the same time. And likewise OK bind all attribute of Text Field and data source calm. The first when choose a record next pulling
[Type of data of 6-7 of graph of graph 6-6 Binding] [chooses] [graph 6-8 binds calm attribute]
List, install the Text Field attribute that is bound to decide by data source.
STEP 3 data is newer
In updating the Server Behaviors in can clicking Application face plate as to data " + " pushbutton, choose Update Record.
[Graph 6-9 chooses Update Record]
[Graph 6-10 installs correlation]
In shooting the dialog box that give, the data source correlation that needs to will input casing and photograph correspondence to update rises, set data kind. Among them CODE should be key word namely Primary Key. Be similar to the page of Insert Record, the setting is added successfully and add failure to jump even the page that turns.
Can preview the page that has made now. Input network address Http://yoursite/location3.aspx, can see the page of the 6-11 that be like a graph.
[Page of graph 6-11 Location3.aspx is browsed]
One of Location_name can be clicked, will jump to detail page Modify.aspx.
[Graph 6-12 updates a page to preview]
Through Modify.aspx the page can revise existing data, can refer incident to update data through expressing sheet.
The main code that its update is as follows:
<MM:UPdate
Runat="server "
CommandText='<%# "UPDATE LOCATIONS SET CITY= ? , STATE_COUNTRY= ? , FAX= ? , TELEPHONE= ? , ADDRESS= ? WHERE CODE= ? "% >'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNEC TION_STRING_location") % >'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_location") % >'
Expression='<%# Request.Form("MM_update") = "form1" % >'
CreateDataSet="false "
SuccessURL='<%# "location3.aspx" % >'
Debug="true "
>
<Parameters>
<Parameter Name="@CITY" Value='<%# IIf((Request.Form("city" )<>Nothing) , request.Form("city") , "") % >' Type="WChar" />
<Parameter Name="@STATE_COUNTRY" Value='<%# IIf((Request.Form("state" )<>Nothing) , request.Form("state") , "") % >' Type="WChar" />
<Parameter Name="@FAX" Value='<%# IIf((Request.Form("fax" )<>Nothing) , request.Form("fax") , "") % >' Type="WChar" />
<Parameter Name="@TELEPHONE" Value='<%# IIf((Reques t.Form("tele" )<>Nothing) , request.Form("tele") , "") % >' Type="WChar" />
<Parameter Name="@ADDRESS" Value='<%# IIf((Request.Form("address" )<>Nothing) , request.Form("address") , "") % >' Type="WChar" />
<Parameter Name="@CODE" Value='<%# IIf((Request.Form("hiddenField" )<>Nothing) , request.Form("hiddenField") , "") % >' Type="WChar" />
</ Parameters >
</ MM:UPdate >
Dreamweaver MX is to pass Mm:uPdate will express those who know updated code. Its format and MM:INsert is similar.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment