Click here to Skip to main content
14,695,532 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i have datatable with column string (Columnname = fname)

i want to add list in one of column in this datatable .

so if i have sname="zxc","erD","gyh","qqq"

i want to add a column like sname and values must be list with values ( "zxc","erD","gyh","qqq") along with fname

how to do this in asp.net
Posted
Comments
Prasad Avunoori 27-Jun-14 5:54am
   
You may user Generic List<> for that.
maulikshah1990 27-Jun-14 5:55am
   
Hi thanks for reply..

can u give example on who to make column as list type and add some values..


1 solution

public class Student
   {
       public int StudentId { get; set; }
       public string StudentName { get; set; }
       public virtual List<Course> Courses { get; set; }
   }

   public class Course
   {
       public int CourseId { get; set; }
       public string CourseName { get; set; }
   }



public List<student> GetStudentList()
        {
            List<student> objStudents = new List<student>()
                                        {
                                        new Student { 
                                                        StudentId = 1, 
                                                        StudentName = "Prasasd", 
                                                        Courses = new List<course> {new Course{ CourseId=101, CourseName="Java"}, new Course{ CourseId=102, CourseName="DotNet"}} 
                                                        
                                                    },
                                                        new Student { 
                                                        StudentId = 2, 
                                                        StudentName = "Ram", 
                                                        Courses = new List<course> {new Course{ CourseId=101, CourseName="Java"}, new Course{ CourseId=102, CourseName="DotNet"}} 
                                                        
                                                    }
                                        };

            return objStudents;
        }</course></course></student></student></student>
   
Comments
maulikshah1990 27-Jun-14 6:38am
   
Hi
thanks for reply..

but i already informed you i am using datatable , and want to make column as string , and other column as list

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