title: Simplest way to populate dropdownlist in asp.net (code behind)?
body: <p>What is the simplest way to populate a dropdownlist in asp.net (code behind)? I have just learned howto fill a grid using datatable and data adapter. Can datatable and data adapter be used to populate a dropdonlist?
  Here is my attempt..       </p>
  
  <pre><code>public partial class page3 : System.Web.UI.Page
  {
    public DataTable fillmydropdownlist()
    {
       DataTable drpdt = new DataTable();
       string q = "select flightdate from flightdetails";
       SqlCommand cmd = new SqlCommand(q,con);
       try
       {
           SqlDataAdapter da2 = new SqlDataAdapter(cmd);
       }
       catch { }
       return drpdt;
    }
  
    protected void Page_Load(object sender, EventArgs e)
    {
      dbOperation dbo = new dbOperation();
      DataTable dt = new DataTable();
      dt = dbo.fillmydropdownlist();
      DataTable drpdt= new DataTable();
  
      if (dt.Rows.Count &gt; 0)
      {
          DropDownList1.DataSource = drpdt;
          DropDownList1.DataBind();
      }
      else
      {
          Response.Write("No Data");
      }
    }
  }
  </code></pre>