title: populating listview in OnLoad Function
body: <p>I am developing an application in which I am using comboBox and ListView. I want to show the records in Listview from database when the application is launched. And the combBox is used for filtering to display those records in ListView, specified by the comboBox.The problem is that when i launch my application it does not show any thing in ListView (both comboBox and ListView are populated from database). while the comboBox is populated and ListView is not populated. And when I select an item in comboBox, it shows those data in listView. I have used a separate class for dataBase connectivity. my Code is below.</p>
  
  <pre><code>private void EmployeeAttendence_Load(object sender, EventArgs e)
          {
              try
              {
                  table = dbOperation.select("employs.emp_id, employs.emp_name, employs.emp_fname, designation.name from employs inner join designation on designation.id = employs.designation");
                  listView1.Items.Clear();
                  foreach (DataRow row in table.Rows)
                  {
                      listView1.Items.Add(row[0].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[1].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[2].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[3].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add("P");
                  }
  
                  table = dbOperation.select("* from designation");
                  comboBox1.Items.Clear();
                  comboBox1.DataSource = table;
                  comboBox1.DisplayMember = "name";
                  comboBox1.ValueMember = "id";
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.ToString());
              }
          }
  </code></pre>
  
  <p>This is the comboBox filtering coding.</p>
  
  <pre><code>private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
  
              try
              {
                  table = dbOperation.select("employs.emp_id, employs.emp_name, employs.emp_fname, designation.name from employs inner join designation on designation.id = employs.designation where employs.designation = '" + comboBox1.SelectedValue + "'");
  
                  listView1.Items.Clear();
                  foreach (DataRow row in table.Rows)
                  {
                      listView1.Items.Add(row[0].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[1].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[2].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add(row[3].ToString());
                      listView1.Items[listView1.Items.Count - 1].SubItems.Add("P");
                  }
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.ToString());
              }
  
          }
  </code></pre>
  
  <p>And this is my Database Select Query Coding.</p>
  
  <pre><code>public DataTable select(string table_name)
          {
              table = new DataTable();
              command.CommandText = "select " + table_name;
              command.Connection = con;
              con.Open();
              adapter.SelectCommand = command;
              adapter.Fill(table);
              con.Close();
              return table;
          }
  </code></pre>