Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to add vertical data from database to listview in C# windows application?
Posted
Comments
Tejas Vaishnav 2-Oct-13 6:40am    
what you have tried so far and where you are getting stuck?
and what is vertical data?
ganesh89_babu 2-Oct-13 6:41am    
still now i not all tried yet i am keep on trying

1 solution

Hi, try like this to load data from database and bind to Listview in asp.net
C#
protected void Page_Load(object sender, EventArgs e)
   {
       OleDbConnection con = new OleDbConnection("Your Connection String");
       con.Open();
       string str = "select * from test Query";
       OleDbCommand com = new OleDbCommand(str, con);
       OleDbDataAdapter oledbda = new OleDbDataAdapter(com);
       DataSet ds = new DataSet();
       oledbda.Fill(ds, "test Query");
       con.Close();
       DataTable dt = ds.Tables["test Query"];
       int i;
       for (i = 0; i <= dt.Rows.Count - 1; i++)
       {
           listView1.Items.Add(dt.Rows[i].ItemArray[0].ToString());
           listView1.Items[i].SubItems.Add(dt.Rows[i].ItemArray[1].ToString());
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900