Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having a list populated from a database, i want to bind this list to a datagrid, any

assistance will be appreciated. below is my code:

C#
 public List<string> listUserNameDuplicate = new List<string>();
 public List<string> listUserName = new List<string>();
while (reader.Read())
                {
                    
                    listUserName.Add(reader["FirstName"].ToString().ToUpper());
                    listUserNameDuplicate.Add(reader["LastName"].ToString().ToUpper());
                    listUserNameDuplicate.Add(reader["FirstName"].ToString().ToUpper());
                    listUserNameDuplicate.Add(reader["MiddleName"].ToString().ToUpper());
                    listUserNameDuplicate.Add(reader["ClassName"].ToString().ToUpper());
                   
               }


i am calling the list in this way:

C#
listBoxDuplicate.DataSource = Wr.listUserNameDuplicate.ToList();


it displays the list items in one row only, and they are all integer values, i want to display Firstname, LastName,MiddleName,ClassName as header text in the datagrid and their

corresponding records below.


And i also want to check whether the listUserName contains more than one username.

Any assistance will be appreciated. Thanks in advance.
Posted
Updated 16-Apr-14 1:45am
v3

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