title: ASPxGridView1.Selection is always = 0 and ASPxGridView1.GetSelectedFieldValues doesnt work
body: <p>simply I'm trying to get selected rows from devexpress gridview, but it never works for me, I have tried client side and custom call back, and tried server side, but it didnt work, spend 10 hours searching and tried every solution that I got but nothing worked for me, could someone please give me a hint, what I'm missing?, here is the code:</p>
  
  <p>default.aspx:</p>
  
  <pre><code>&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
  &lt;script type="text/javascript"&gt;
      &lt;/script&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
      &lt;div&gt;
  
          &lt;dx:ASPxGridView ID="ASPxGridView1" ClientInstanceName="ASPxGridView1"  KeyFieldName="ID" AutoGenerateColumns="False" runat="server"&gt;
              &lt;Columns&gt;
                  &lt;dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" 
                      Caption="Select" Name="Select"&gt;
                  &lt;/dx:GridViewCommandColumn&gt;
                  &lt;dx:GridViewDataTextColumn Caption="ID" FieldName="pag_id_pk" Name="ID" 
                      VisibleIndex="1"&gt;
                  &lt;/dx:GridViewDataTextColumn&gt;
                  &lt;dx:GridViewDataTextColumn Caption="Name" FieldName="pag_name" Name="Name" 
                      VisibleIndex="2"&gt;
                  &lt;/dx:GridViewDataTextColumn&gt;
                  &lt;dx:GridViewDataTextColumn Caption="Title" FieldName="pag_title" Name="Title" 
                      VisibleIndex="3"&gt;
                  &lt;/dx:GridViewDataTextColumn&gt;
              &lt;/Columns&gt;
          &lt;/dx:ASPxGridView&gt;
          &lt;dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Get Values" UseSubmitBehavior="False" onclick="ASPxButton1_Click" /&gt;
      &lt;/div&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>default.cs:</p>
  
  <pre><code>public partial class _Default : System.Web.UI.Page
  {
      DataTable table = null;
      protected void Page_Init(object sender, EventArgs e)
      {
          if (!IsPostBack &amp;&amp; !IsCallback)
          {
              string connectionString = ...
              con.Open();
              SqlDataReader rd;
              SqlCommand cmd = new SqlCommand("SELECT * FROM [Pages]", con);
              rd = cmd.ExecuteReader();
  
              DataTable dt = new DataTable();
              dt.Load(rd);
  
              ASPxGridView1.DataSource = dt;
  
              Session["dt"] = (DataTable)dt;
              ASPxGridView1.DataBind();
              rd.Close();
              con.Close();
          }
      }
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
      protected void ASPxButton1_Click(object sender, EventArgs e)
      {
          List&lt;object&gt; indexes = new List&lt;object&gt;();
          for (int i = 0; i &lt; ASPxGridView1.VisibleRowCount; i++)
          {
              if (ASPxGridView1.Selection.IsRowSelected(i))
              {
                  indexes.Add(ASPxGridView1.GetRowValues(i, ASPxGridView1.KeyFieldName));
              }
          }
  
          foreach (var selectedKey in ASPxGridView1.GetSelectedFieldValues(ASPxGridView1.KeyFieldName))
          {
              if (!indexes.Contains(selectedKey))
                  ASPxGridView1.Selection.UnselectRowByKey(selectedKey);
          }
      }
  </code></pre>
  
  <p>Thanks in advance...</p>
  
  <p>Update:
  when I used "asp:SqlDataSource" it works fine.</p>