請參考這個網址爲您解決問題
https://www.devexpress.com/Support/Center/Example/Details/E308
改變你填入電網邏輯
ASPX:
<dx:ASPxGridView ID="ASPxGridView1" runat="server"></dx:ASPxGridView>
CS
protected void Page_Init(object sender, EventArgs e)
{
ASPxGridView1.KeyFieldName = "ID";
ASPxGridView1.DataSource = GetData();
if (!IsPostBack && !IsCallback)
{
PopulateColumns();
ASPxGridView1.DataBind();
}
}
public DataTable GetData()
{
DataTable Table = new DataTable();
Table.Columns.Add("ID", typeof(int));
Table.Columns.Add("ItemName", typeof(string));
Table.Columns.Add("ItemValue", typeof(string));
Table.Rows.Add(1, "A","AA");
Table.Rows.Add(2, "B","BB");
return Table;
}
public void PopulateColumns()
{
GridViewDataTextColumn colID = new GridViewDataTextColumn();
colID.FieldName = "ID";
ASPxGridView1.Columns.Add(colID);
GridViewDataTextColumn srk = new GridViewDataTextColumn();
srk.FieldName = "ItemValue";
ASPxGridView1.Columns.Add(srk);
GridViewDataHyperLinkColumn colItemName = new GridViewDataHyperLinkColumn();
colItemName.FieldName = "ItemValue";
colItemName.PropertiesHyperLinkEdit.NavigateUrlFormatString = "~/details.aspx?Device={0}";
colItemName.PropertiesHyperLinkEdit.TextFormatString = "{0}";
colItemName.PropertiesHyperLinkEdit.TextField = "ItemName";
ASPxGridView1.Columns.Add(colItemName);
}
這裏如果你要根據多個列中顯示超鏈接文本,然後HyperlinkColumn不實施正確的方法列ITEMNAME指項目值作爲URL字符串PARAMS
感謝您的答覆,但我不知道如何解決我的問題。我相信這個例子只是格式化了單元格的當前值。如果列0的行0的字符串爲「value1」,列3的行0的字符串爲「value2」,那麼如何格式化第3列的url以包含列0的值。在這個例子中,列3行0將具有鏈接:「〜/ details.aspx?Device = value1」。 – DMC
我已根據您的需要更改我的代碼,我希望這可能有所幫助。 –