C#数据绑定BindingSource,如何使用过滤后的数据集
设置数据集及过滤器,这样就可以在不同的视图下呈现
dataTable = BO_Team.GetDataList_Member(); bind_Member.DataSource = dataTable; //数据绑定 bind_Member.Filter = string.Format("team_sn='{0}'", BO_member.Team_Sn); //设置筛选条件
通过DataView .ToTable()获取过滤后的数据集
void updateMembers() { string members = ""; DataView dv; dv = ((DataTable)bind_Member.DataSource).DefaultView; dataTable = dv.ToTable(true, "staff_name"); if (dataTable.Rows.Count == 0) { members = ""; } else { members = dataTable.Rows[0][0].ToString(); for (int i = 1; i < dataTable.Rows.Count; i++) { members += "," + dataTable.Rows[i][0].ToString(); } } txtMembers.Text = members; bind_Team.EndEdit(); }