Use a link to display a detailed page.
In the past, when using UltraDev, linking to a detailed data page was usually done through the "Go To Detail Page" server behavior. However, this behavior is not provided in the server behavior window in the NET environment. So what should I do with the link? What to do? The answer lies in the settings of the DataGrid control.
For convenience of explanation, we also put the elements of the detail page in the default.aspx page.
First create a record set "DataSet2" to display detailed information. The creation method is very simple. As shown in the figure, just set the serial number to the "xid" parameter passed by the URL.
Insert a table into the page, bind the fields in the "DataSet2" record set to the appropriate positions in turn, and don't forget to use Server Behaviors → Show Region → Show If DateSet Is Not Empty to set the behavior when the "DataSet2" record set is Hide the table when empty, as shown below.
After completion, we need to edit the DataGrid control again, set the serial number in the dialog box to the link that passes the "xid" parameter, select "Serial Number" in the "Columns" field, and then click the "Change Column Type" button below to convert the column type and select " Hyperlink" hyperlink item
Set the following settings in the pop-up "Hyperlink Culumn" dialog box
Title: "Serial Number" - displays the title of the column
Hyperlink Text: - Hyperlink text, including three items here
Static Text: - You can write text here as a link
Data Field: "Serial Number" - you can select a field in the recordset as a link
Format String:——You can define the display format of the field
Linked Page:——The page linked to, there are also three items here
Static URL: - Link to a static page
Date Field: "Serial Number" - This refers to selecting the "Serial Number" field as the parameter value passed to the next page. Format String: "default.aspx?xid={0}" - Use the button on the right to select the page to link to. , our detailed records are also on this page. Just select "default.aspx" to generate the previous string. It should be noted that the automatically generated parameter name is the Chinese "serial number" text. When we create the "DataSet2" record set The specified parameter is named "xid", so it needs to be modified manually here.
After completion, as shown below
Click "OK" to return to save and test it.
Some other additions
1. We have used four display types in the DataGrid control and basically know how to use them. The remaining one is "Free Form". This is a relatively free display type. You can add and merge several dynamic records here or add text to them. It can also be an expression control. In short, this is a flexible display method provided.
2. You should still remember that when we edited the "Hyperlink Culumn" hyperlink dialog box, there was a "Format String" item that was set to empty. How to set it if needed? After reading the ASP.NET documentation, we tried the following, adding the string "{0:X}" in this box, as shown below
After saving, we can see the following picture in the browser
The "serial number" field displays the value in hexadecimal format because of the format character "X". Here are several format character descriptions
C displays the value in currency format.
D Displays the value in decimal format.
E Displays numeric values in scientific notation (exponential) format.
F displays numerical values in a fixed format.
G Displays numeric values in regular format.
N displays the value in numeric format.
X displays the value in hexadecimal format.
3. What should I do if the link that requires the "serial number" field is opened in the form of a new window? This function does not seem to be provided in the DataGrid control this time. Let's try to change the source code. Go to the source code window and find the code corresponding to the "Serial Number" field:
DataNavigateUrlField="serial number"
DataNavigateUrlFormatString="default.aspx?xid={0}"
DataTextField="serial number"
Visible="True"
HeaderText="serial number"/>
Add the "Target="_new"" string at the end of the code to make it
DataNavigateUrlField="serial number"
DataNavigateUrlFormatString="default.aspx?xid={0}"
DataTextField="serial number"
Visible="True"
HeaderText="serial number"
Target="_new" />
Okay, that's it. When you click the link record on the serial number again, it will appear in the form of a new window.
These are the basic uses of the DataGrid control in the ASP.NET environment in Dreamweaver MX. Of course, you can modify the code to get more functions. As the old saying goes, Dreamweaver MX can provide efficiency when you develop ASP.NET, and the functions it currently has It is still very insufficient, so looking at the source code and understanding the source code is still the key to using Dreamweaver MX well.