Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. listview problem

listview problem

Scheduled Pinned Locked Moved C#
questionhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    angels777
    wrote on last edited by
    #1

    hi.. i have a question related to the listview.. i did the below things.. but how do i assign the value to the listview /?

    void call_listview()
    {
    cmd.Connection = con;
    cmd.CommandText = "select * from contact";
    da.SelectCommand = cmd;

            DataTable store = new DataTable();  
            try
            {
               
                ds.Clear();
                con.Open();
                da.Fill(ds);
                store = ds.Tables\[0\];
    
                int count\_friend = store.Rows.Count;
                contact\_total\_friends.Content = count\_friend;
               
                contact\_listview.DataContext = ds.Tables\[0\].DefaultView;
            }
    
            catch (Exception ex)
            {                
                MessageBox.Show(ex.Message);            
            }
            finally
            {
                con.Close();
            }
        }
    
    J 1 Reply Last reply
    0
    • A angels777

      hi.. i have a question related to the listview.. i did the below things.. but how do i assign the value to the listview /?

      void call_listview()
      {
      cmd.Connection = con;
      cmd.CommandText = "select * from contact";
      da.SelectCommand = cmd;

              DataTable store = new DataTable();  
              try
              {
                 
                  ds.Clear();
                  con.Open();
                  da.Fill(ds);
                  store = ds.Tables\[0\];
      
                  int count\_friend = store.Rows.Count;
                  contact\_total\_friends.Content = count\_friend;
                 
                  contact\_listview.DataContext = ds.Tables\[0\].DefaultView;
              }
      
              catch (Exception ex)
              {                
                  MessageBox.Show(ex.Message);            
              }
              finally
              {
                  con.Close();
              }
          }
      
      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Have you looked at any articles on this site regarding ListView databinding? A quick search reveals Data binding a ListView[^]

      Life, family, faith: Give me a visit. From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'" Judah Himango

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups