|
-
January 17th, 2009, 08:41 PM
#1
C sharp LISTVIEW - help please?
here how the code looks:
connection.Open();
string txtSql = "select EmployeeID, Lastname, FirstName, Title, TitleOfCourtesy, HireDate, Address, City, Homephone from Employees";
SqlCommand cmd = new SqlCommand(txtSql, connection);
SqlDataReader dr = cmd.ExecuteReader();
ListViewItem a;
while (dr.Read())
{
a = new ListViewItem();
for (int i=1; i < dr.FieldCount; i++)
{
a.Text = Convert.ToString(dr.GetValue(i));
ListViewItem.ListViewSubItem bla = new ListViewItem.ListViewSubItem(a, a.Text.ToString());
a.SubItems.Add(bla);
}
listView1.Items.Add(a);
}
dr.Close();
connection.Colse();
The output in the listview1 is: http://img140.imageshack.us/img140/3005/notcm1.png
but the first collumn should be filled from the id collumn of the db table and not phone!
What I'm missing?! Please somebody help...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|