我正在用所有必要的数据填写一个 DataTable。我希望“进程”列包含一个超链接,以便在单击时指向特定页面(基于进程名称。
这是我到目前为止的代码:
Object[] row = new Object[7];
HyperLink link = new HyperLink();
link.Text = Process.ToString();
link.NavigateUrl = String.Format("~/IndexSummary?Process={0}", Process.ToString());
row[0] = link;
//...Fill in rest of row
dt.LoadDataRow(row,false);
GridView1.DataSource = dt;
GridView1.DataBind();
当我执行此代码时,每一行都会显示“System.Web.UI.WebControls.HyperLink”。这是我的 GridView 代码:
<asp:GridView ID="GridView1" runat="server" CellPadding="3"
ForeColor="#333333" GridLines="None"
AllowSorting="True" SortedAscendingHeaderStyle-CssClass="sortasc-header"
SortedDescendingHeaderStyle-CssClass="sortdesc-header" AutoGenerateSelectButton="True"
AllowPaging="True" PageSize="17" PagerSettings-Mode="NextPreviousFirstLast"
ShowHeaderWhenEmpty="True" PagerStyle-Font-Names="WebDings" PagerStyle-Font-Size="Medium"
PagerSettings-FirstPageText=" 7 " PagerSettings-PreviousPageText=" 3 "
PagerSettings-NextPageText=" 4 " PagerSettings-LastPageText=" 8 "
Font-Size="Small" onselectedindexchanged="GridView1_SelectedIndexChanged"
onpageindexchanging="GridView1_PageIndexChanging"
onsorting="GridView1_Sorting">
<AlternatingRowStyle BackColor="White" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerSettings FirstPageText=" 7 " LastPageText=" 8 " Mode="NextPreviousFirstLast" NextPageText=" 4 " PreviousPageText=" 3 "></PagerSettings>
<PagerStyle BackColor="#5D7B9D" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#DCE2E8" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingHeaderStyle CssClass="sortasc-header"></SortedAscendingHeaderStyle>
<SortedDescendingHeaderStyle CssClass="sortdesc-header"></SortedDescendingHeaderStyle>
</asp:GridView>
如何更改它以正确显示超链接?