views:

131

answers:

1

Hi, We are using AspXGridView devXgrid for our web application. I have to assign two values (id,value) for a column in the grid. How can I do this?

Thanks, P.Gopalakrishnan.

A: 

This opens up a can of worms. If you have sorting, grouping, and/or filtering enabled, how should those work?

There are a bunch of ways to do this, here's one (ignoring the other issues)...

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

Greg