Not logged in - Login

Basic ASPxGridView Grid Data Display

Add the DevExpress grid to the web page. Use the designer to add columns to the grid. Be sure to specify the 'FieldName' property of each column. This value determines what field from the data source is displayed in the column. The following illustrates a sample of how the grid source will look in the HTML:

<dxwgv:ASPxGridView ID="grdTest" runat="server" AutoGenerateColumns="False">
      <dxwgv:GridViewDataTextColumn Caption="lRowID" FieldName="lRowID" Name="lRowID" VisibleIndex="0" ReadOnly="True">

      <dxwgv:GridViewDataTextColumn Caption="sText" FieldName="sText" Name="sText" VisibleIndex="1">

      <dxwgv:GridViewDataTextColumn Caption="lNumber" FieldName="lNumber" Name="lNumber" VisibleIndex="2">

      <dxwgv:GridViewDataDateColumn Caption="dtDate" FieldName="dtDate" Name="dtDate" VisibleIndex="3">
         <PropertiesDateEdit DisplayFormatString="M/d/yyyy">

      <dxwgv:GridViewDataCheckColumn Caption="bFlag" FieldName="bFlag" Name="bFlag" VisibleIndex="4">

      <dxwgv:GridViewDataComboBoxColumn Caption="lNumberCbo" FieldName="lNumber" Name="lNumberCbo" VisibleIndex="5">
         <PropertiesComboBox ValueType="System.String">
         <dxe:ListEditItem Text="Zero" Value="0" />
         <dxe:ListEditItem Text="One" Value="1" />
         <dxe:ListEditItem Text="Two" Value="2" />
         <dxe:ListEditItem Text="Three" Value="3" />
         <dxe:ListEditItem Text="Four" Value="4" />

   <SettingsPager PageSize="10">

In the Load event of the form, retrieve the data and bind it to the grid. It will look something like the following:

// get the sample data
DataTable tbl = null;
tbl = SampleData.GetSampleData1();

// bind the data to the grid.
this.grdTest.DataSource = tbl;
if (!this.IsPostback && !this.IsCallback)

This must be done every time the Load event is fired on the form, even on postbacks.