How to use a dataset and display that data in a listview dropdown list select box.

DATASETS LISTVIEW DROPDOWN SELECTBOX

C# Tutorials

  

DATASETS LISTVIEW DROPDOWN SELECTBOX

Learn Tutorials
How to use a dataset and display that data in a listview dropdown list select box.

Example code for Datasets listview dropdown selectbox:
public DataSet getDataSet(string query, string tableName)
   {

      SqlDataAdapter da = new SqlDataAdapter();

      SqlCommand cmd = new SqlCommand(query);

      DataSet ds = new DataSet();

      //load the data into the dataset
      da.Fill(ds,tableName);
      return ds;
   }


   //dump the dataset returned into the listview
   foreach (DataRow dr in ds.Tables["Data"].Rows)
   {
      lvi=new ListViewItem();
      lvi.Text=dr["Title"].ToString();
      DateTime date =(DateTime)dr["dateInserted"];
      lvi.SubItems.Add(date.DayOfWeek.ToString());
      lvi.SubItems.Add(dr["dateInserted"].ToString());

      bottomListView.Items.Add(lvi);
   }
This is example code for how to use a dataset and display that data in a listview dropdown list select box.