标签:tostring 集合 ble tar load reac class add 数据
public IList<Student> IStudent = new List<Student>();
public BindingList<Student> BStudent = new BindingList<Student>();
/// <summary>
/// 加载数据返回IList
/// </summary>
IList<Student> BindDataList(DataTable dt)
{
IStudent.Clear();
foreach (DataRow row in dt.Rows)
{
Student student = new Student();
student.Name = row["name"].ToString();
student.Sex = row["sex"].ToString();
IStudent.Add(student);
}
IStudent.Add(new Student() { Name = "2", Sex = "3" });
return IStudent;
}
/// <summary>
/// 绑定数据
/// </summary>
public void Loading()
{
BStudent = new BindingList<Student>(BindDataList(dt));
gridControl1.DataSource = BStudent;
}
/// <summary>
/// 实体类
/// </summary>
public class Student
{
public string Name { get; set; }
public string Sex { get; set; }
}
标签:tostring 集合 ble tar load reac class add 数据
原文地址:https://www.cnblogs.com/Csharp-Soul/p/11608137.html