title: How to access DataGrid in separate class passed from another function
body: <p>I am creating a separate DataAcessLayer for DB connection/operations in my WPF Application.</p>
  
  <p>I was creating separate function in the class so as to directly pass a Datagrid and select query to bind that datagrid.</p>
  
  <p>It was made as below:</p>
  
  <pre><code> private void FillDataGrid(string sql, DataGrid grd)
          {
                  SqlCommand cmd = new SqlCommand(sql, conn);
                  SqlDataAdapter sda = new SqlDataAdapter(cmd);
                  DataTable dt = new DataTable("Employee");
                  sda.Fill(dt);
          }
  </code></pre>
  
  <p>Here i am passing select query and data grid from other class as </p>
  
  <pre><code>FillDataGrid("select * from emp",grdEmp);
  </code></pre>
  
  <p>But when i was trying to bind datagrid   <code>FillDataGrid</code> function i was not finding:</p>
  
  <p><code>grd.Itemsource</code> in it.</p>
  
  <p>how can i access/bind DataGrid in that function</p>