如何在网格中为列提供两个值

时间:2009-05-07 11:40:28

标签: data-binding advanceddatagrid aspxgridview

我们正在为我们的Web应用程序使用AspXGridView devXgrid。我必须为网格中的列分配两个值(id,value)。我怎么能这样做?

谢谢, P.Gopalakrishnan。

1 个答案:

答案 0 :(得分:0)

这会打开一堆蠕虫。如果您启用了排序,分组和/或过滤,那么它们应该如何工作?

有很多方法可以做到这一点,这是一个(忽略其他问题)......

protected void ASPxGridView1_Init(object sender, EventArgs e) {
    // Creates a column, customizes its settings and appends it to the Columns collection;
    GridViewDataTextColumn colTotal = new GridViewDataTextColumn();
    colTotal.Caption = "IdValue";
    colTotal.FieldName = "IdValue";
    colTotal.UnboundType = DevExpress.Data.UnboundColumnType.String;
    colTotal.VisibleIndex = ASPxGridView1.VisibleColumns.Count;
    ASPxGridView1.Columns.Add(colTotal);
}
// Populates the unbound column.
protected void ASPxGridView1_CustomUnboundColumnData(object sender, ASPxGridViewColumnDataEventArgs e) {
    if (e.Column.FieldName == "IdValue") {
        e.Value = e.GetListSourceFieldValue("Id") + " " +  e.GetListSourceFieldValue("Value");
    }
}

http://devexpress.com/Help/?document=ASPxGridView/CustomDocument3770.htm&levelup=true