ASPxGridView Screencast: Unbound Columns

29 November 2007

In this screencast you’ll learn how to display unbound data using unbound columns.

Unbound data is typically data that does not come from your datasource. Data like calculated columns which you can easily define in the ASPxGridView.

Check out the screencast and then let me know your thoughts. A how-to is also posted below. Thanks!

image

 


 

How to create Unbound Columns in the ASPxGridView

To add an Unbound column just follow these easy steps:

  1. Add a new column to the ASPxGridView
  2. Assign the data value in the CustomUnboundColumnData event

Add the new unbound column

Click on the smart tag of the ASPxGridView and select Columns from the menu. The columns editor form you see below will appear. Use the two icons on the top left corner of the form to add or insert a new column. When clicking on one of these buttons, a dropdown will appear that let's you select the type of column to add. You can select any type that fits your column/data type but the Text Column is the general type:

image

Now define some properties for the column like the Caption(header), FieldName, UnboundType, and possibly DisplayFormatString. Since this is an unbound column, you should define UnboundType to match the data type you'll be adding to the field. The FieldName will be used when filling the value and must be unique from any other fields in your datasource.

image

Assign a value to your unbound column

To fill the new column with data, you should handle the CustomUnboundColumnData event. Here you can assign the data value using the e.Value property. In the sample, note the e.GetListSourceFieldValue method and e.Column.FieldName property. You can use these items to check for the column and field values in the method.

image

Now run the application and you have the unbound column you just created with just a few easy steps.

12 comment(s)
John Frost2

Bravo.  This is precisely what is needed.  Please keep them coming.

30 November, 2007
Shankar

Great Show. Just Waiting for It

30 November, 2007
Mehul Harry (DevExpress)

Thanks Guys, there are some more in the pipeline.

30 November, 2007
Danilo Cruz

Hi,

I need to create a new unbound column (Button) and implement an event to it at server. How can I do that?

Thank you.

19 February, 2008
Edgard Penado

How Calculate Column on selected row or on change an Control NumericBox ?

27 May, 2009
Tor Anders Johansen

How can I bind to a unbound column in a EditForm-Template? I want a literal to display the value also when editing, but Bind("unbound") returns a empty string...

10 November, 2009
Tor Anders Johansen

I found a solution, binding to Text-property of <dxe:ASPxLabel> instead of Text-property of <asp:Literal> worked.

11 November, 2009
Reddy Ojili

Please update the screencast link. it's broken.

19 March, 2010
Mehul Harry (DevExpress)

@Reddy,

Fixed the link in the post. Screencast should point here now:

tv.devexpress.com

19 March, 2010
Martin Guerrero

Hi Mehul, i need a aspxgridview that work without SQLDatasourse, i mean that i created de columns and the rows, but when i created the columns i can't edit i can´t write nothing. Is posible that i can do that, have a aspxgridview only for write data

26 July, 2012
Mehul Harry (DevExpress)

Martin,

The ASPxGridView can work with any IEnumerable data source. You can bind it dynamically. However, if you want to edit data, your datasource should support the edit commands.

26 July, 2012
brian wh

Very awsome. Just what I needed! Thanks

2 August, 2012

Please login or register to post comments.