在数据表中添加列表作为列值 [英] add list in datatable as column value
本文介绍了在数据表中添加列表作为列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
i有数据表的列字符串(Columnname = fname)
i想在列之一中添加列表在这个数据表中。
所以,如果我有sname =zxc,erD,gyh,qqq
i想要添加像sname这样的列,值必须列出值(zxc,erD,gyh,qqq)以及fname
如何在asp.net中执行此操作
解决方案
公开 类学生
{
public int StudentId { get ; set ; }
public string StudentName { get 跨度>; set ; }
public virtual 列表<课程>课程{获取; set ; }
}
public class 课程
{
public int CourseId { get ; set ; }
public string CourseName { get 跨度>; set ; }
}
public List< student> GetStudentList()
{
List< student> objStudents = new 列表< student>()
{
new 学生{
StudentId = 1 ,
StudentName = Prasasd,
Courses = new 列表< course> { new 课程{CourseId = 101 ,CourseName = Java}, new 课程{CourseId = 102 ,CourseName = DotNet}}
} ,
new 学生{
StudentId = 2 ,
StudentName = Ram,
Courses = new 列表< course> { new 课程{CourseId = 101 ,CourseName = Java}, new 课程{CourseId = 102 ,CourseName = DotNet}}
}
};
return objStudents;
} < / 课程 > < / 课程 > < / 学生 > < span class =code-keyword>< / student > < / 学生 >
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
解决方案
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>
这篇关于在数据表中添加列表作为列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文