title: Command parameter to void from DataGrid
body: <p>I have a datagrid with several columns. One of them is the idObiektu. I would like to pass idObiektu (from the selected row) as a parameter of command</p>
  
  <p>In View i have</p>
  
  <pre><code>&lt;Button Content="Usun" Command="{Binding UsunCommand}"  CommandParameter="{Binding idObiektu}" /&gt;
  
  &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Header="Identyfikator" Binding="{Binding idObiektu}"/&gt;
                      &lt;DataGridTextColumn Header="Nazwa obiektu" Binding="{Binding Nazwa}" /&gt;
                  &lt;DataGridTextColumn Header="Adres" Binding="{Binding Adres}"/&gt;
                      &lt;DataGridTextColumn Header="Pojemność obiektu" Binding="{Binding Pojemnosc}" /&gt;
                      &lt;DataGridTextColumn Header="Osoba kontakotwa" Binding="{Binding OsobaKontaktowa}"/&gt;
                      &lt;DataGridTextColumn Header="Numer telefonu" Binding="{Binding Telefon}"/&gt;
                      &lt;DataGridTextColumn Header="Adres email" Binding="{Binding Email}"/&gt;
                      &lt;DataGridTextColumn Header="Notatki" Binding="{Binding Notatki}"/&gt;
  &lt;/DataGrid.Columns&gt;
  </code></pre>
  
  <p>In View model i have</p>
  
  <pre><code>public string idObiektu
          {
              get
              {
                  return _idObiektu;
              }
              set
              {
                  if (_idObiektu != value)
                  {
                      _idObiektu = value;
                      OnPropertyChanged(() =&gt; idObiektu);
                  }
  
              }
          }
  
  public ICommand UsunCommand { get { return new RelayCommand&lt;string&gt;(OnEdit); } }
  
          private void OnEdit(string itemToEdit)
          {
  
                  int idObiektu = Int32.Parse(itemToEdit);
                  atmaEntites.Database.ExecuteSqlCommand("UPDATE Obiekty SET stan = '2' WHERE idObiektu = " + idObiektu + ";");
          }
  
  </code></pre>
  
  <p>I have problem, since every time <strong>itemToEdit</strong> is null</p>
  
  <p>I try change VievModel to this, and <strong>test string o is NULL</strong></p>
  
  <pre><code>public ICommand UsunCommand { get { return new RelayCommand&lt;object&gt;(OnEdit); } }
  
          private void OnEdit(object itemToEdit)
          {
              string o = itemToEdit.ToString();
              if (itemToEdit is null)
              {
                  string idObiektu = itemToEdit.ToString(); ;
                  atmaEntites.Database.ExecuteSqlCommand("UPDATE Obiekty SET stan = '2' WHERE idObiektu = " + idObiektu + ";");
              }
              else
              {
                  string idObiektu = itemToEdit.ToString(); ;
                  atmaEntites.Database.ExecuteSqlCommand("UPDATE Obiekty SET stan = '2' WHERE idObiektu = " + idObiektu + ";");
              }
          }
  </code></pre>