<asp:HyperLink Width="80px" ID="HyperLink1" runat="server" Target="_blank" NavigateUrl=<%# "abc.aspx?bak="+Eval("bak")+"&status="+Eval("status")%>><%#Eval("bak").ToString()%></asp:HyperLink>
如果status为1,链接到ebeln.aspx页面,
如果status为2,那么链接到运行wlsg.aspx页面
如果status为1,链接到ebeln.aspx页面,
如果status为2,那么链接到运行wlsg.aspx页面
This example demonstrates using a hyperlink column. The code below
should be copied into a file called HyperTextColumnCS.aspx. The file
should be stored in the same directory as the file DetailsPageCS.aspx
described below.
-->
...<%@ Page language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Data" %><html>
<head>
<script runat="server">
private DataView dv;
private DataTable dt = new DataTable(); private void Page_Load(object sender, System.EventArgs e)
{
// Create a DataTable to use as the data source for
// the DataGrid.
dt.Columns.Add(new DataColumn("ItemNumber"));
dt.Columns["ItemNumber"].Caption = "Item Number";
dt.Columns.Add(new DataColumn("Item"));
dt.Columns["ItemNumber"].Caption = "Item";
dt.Columns.Add(new DataColumn("Price"));
dt.Columns["ItemNumber"].Caption = "Price"; // Add some data to the DataTable.
DataRow myDataRow;
for (int i = 0; i < 5; i++)
{
myDataRow = dt.NewRow();
myDataRow[0] = i;
myDataRow[1] = "Item " + i.ToString();
myDataRow[2] = 1.23 * (i + 1);
dt.Rows.Add(myDataRow);
}
// Use the table to create a DataView.
dv = new DataView(dt); // Create hyperlink columns that contain the item name
// and price.
HyperLinkColumn nameCol = new HyperLinkColumn();
nameCol.DataNavigateUrlField = "ItemNumber";
nameCol.DataTextField = "Item";
nameCol.DataNavigateUrlFormatString =
"DetailspageCS.aspx?id={0}";
nameCol.HeaderText = dt.Columns["Item"].Caption; HyperLinkColumn priceCol = new HyperLinkColumn();
priceCol.DataNavigateUrlField = "ItemNumber";
priceCol.DataTextField = "Price";
priceCol.DataNavigateUrlFormatString =
"DetailspageCS.aspx?id={0}";
priceCol.DataTextFormatString = "{0:c}";
priceCol.HeaderText = dt.Columns["Price"].Caption; // Add the new columns to the DataGrid.
DataGrid1.Columns.Add(nameCol);
DataGrid1.Columns.Add(priceCol); // Set the DataView as the data source, and bind
// it to the DataGrid.
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
} private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = (ListItemType)e.Item.ItemType; if ((itemType != ListItemType.Header) &&
(itemType != ListItemType.Footer) &&
(itemType != ListItemType.Separator))
{ // Get the IntegerValue cell from the grid's column
// collection.
TableCell currentCell = (TableCell)e.Item.Controls[0];
DataGrid1.Columns[1].InitializeCell(currentCell, 1,
ListItemType.Item); // Add attributes to the cell.
currentCell.Attributes.Add("id", "currentCell" +
e.Item.ItemIndex.ToString());
currentCell.Attributes.Add("OnClick",
"Update_currentCell" +
e.Item.ItemIndex.ToString() +
"()");
}
}
</script>
</head>
<body>
<form runat="server">
<h3>HyperLinkColumn Example</h3>
<asp:DataGrid Runat="server" ID="DataGrid1" CellPadding="4"
AutoGenerateColumns="False" BorderStyle="None" GridLines="None">
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="Black">
</HeaderStyle>
</asp:DataGrid>
<p>Click on an item name or price to add the item to your order.</p>
</form>
</body>
</html>