如何在devexpress ASPxGridView控件中添加超链接列?

时间:2011-12-06 16:10:37

标签: c# devexpress aspxgridview

我想从Devexpress(c#asp.net)添加我的GridView一个超链接列,我希望将每行的名称设置为数据的值。

这可能吗?怎么样?

1 个答案:

答案 0 :(得分:6)

ASPxGridView documentation关于如何在运行时创建和配置HyperLink列

public void PopulateColumns() {
    GridViewDataTextColumn colID = new GridViewDataTextColumn();
    colID.FieldName = "ID";
    ASPxGridView1.Columns.Add(colID);

    GridViewDataHyperLinkColumn colItemName = new GridViewDataHyperLinkColumn();
    colItemName.FieldName = "ItemName";
    colItemName.PropertiesHyperLinkEdit.NavigateUrlFormatString ="~/details.aspx?Device={0}";
    colItemName.PropertiesHyperLinkEdit.TextFormatString = "Device {0}";
    colItemName.PropertiesHyperLinkEdit.TextField = "ItemName";
    ASPxGridView1.Columns.Add(colItemName);
}