.Net Links

Tuesday, November 17, 2009

How to get Values from a Hidden Column of a Devexpress Grid

There are two way by which we can retrieve values from a column which is hidden


protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)

{
Method 1

object o = (sender as ASPxGridView).GetRowValuesByKeyValue(e.Keys[0], "Description");


Method 2

string rowId = e.Keys[0].ToString();

}

Labels:

Monday, November 16, 2009

How to get Distinct Values from Dataset in single line

How to get unique columns from a dataset using simple command ?

DataTable distinctUniqueCustomer = dataTable.DefaultView.ToTable("Customer", true, "EMPNO");

Where EMPNO is the field Name , Customer is the source DataTable

Labels: ,

Tuesday, November 3, 2009

How to customize Filter Menu for ComboBoxColumn inside the grid


The below event and function will help to customize Filter Menu for ComboBoxColumn to User defined values in a Grid.

The below codes will populate the Filter ComboBoxColumn with values "Yes" / "No" instead of deafault value "Checked / Unchecked"


The below Event is raised which will enable the cells editors displayed within the auto filter row cells to be initialized.

//Event to be raised
Grid.AutoFilterCellEditorInitialize +=new ASPxGridViewEditorEventHandler(gvSubstitutions_AutoFilterCellEditorInitialize);

// Function to replace the text Checked /Unchecked wiht Yes/No in the filter of the ASPxComboBox column
protected void gvSubstitutions_AutoFilterCellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
{
if (e.Column.FieldName == "Active")
{
(e.Editor as ASPxComboBox).Items.Clear();
(e.Editor as ASPxComboBox).Items.Add("Yes", true);
(e.Editor as ASPxComboBox).Items.Add("No", false);
}
}

Labels: , , , ,