Click here to Skip to main content
14,825,880 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi guys,

Please advice me how to bind my data to Gridview

List<string[]> listUser = new List<string[]>();
           using (Stream s = file.InputStream)
               string[] numberOfUsers;
               var sr = new StreamReader(s);
               string contacts = sr.ReadToEnd();
               contacts = contacts.Replace("\r\n", "\n");
               string[] separateLines = contacts.ToString().Split('\n');
               foreach (string line in separateLines)
                   if(line!= String.Empty)
                      numberOfUsers = line.Split(',');
                       if(numberOfUsers.Length > 40)
                           String[] tempData = {
                                                    numberOfUsers[0], /*title*/
                                                    numberOfUsers[1], /*FirstName*/
                                                    numberOfUsers[2], /*MiddleName*/
                                                    numberOfUsers[3], /*LastName*/
                                                    numberOfUsers[57], /*Email*/
                                                    numberOfUsers[15], /*StreetName1*/
                                                    numberOfUsers[16], /*StreetName2*/
                                                    numberOfUsers[21], /*Country*/
                                                    numberOfUsers[19], /*State*/
                                                    numberOfUsers[20], /*PostCode*/
                                                    numberOfUsers[18], /*City*/
                                                    numberOfUsers[37], /*HomePhone*/
                                                    numberOfUsers[40], /*MobilePhone*/
                                                    numberOfUsers[31], /*WorkPhone*/
                                                    numberOfUsers[36]  /*Fax*/


           return listUser;
Updated 16-Oct-10 11:16am

1 solution

See here[^] for a few samples.

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