Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 10th, 2012  |  syntax: None  |  size: 0.38 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to populate a listview from a datatable
  2. DataTable dt = new DataTable();
  3.     SqlConnection conn = new SqlConnection(@"connectionstring");
  4.     SqlCommand ccmd = new SqlCommand("SELECT img FROM '" + user + "'", conn);
  5.     conn.Open();
  6.  
  7.     SqlDataAdapter da = new SqlDataAdapter(ccmd);
  8.     da.SelectCommand = ccmd;
  9.     da.Fill(dt);
  10.        
  11. listView.DataSource = dt;
  12. listView.DataBind();