DEV全选多选小技巧

 var v1 = bindingSourceBase.DataSource as DataTable;
            foreach (DataRowView v in v1.DefaultView)
            {
                v["isUnChecked"] = true;
                //listTemp.Add(ConvertToModel<vwERP_PM_MtlOutDetail>(v.Row));
            }

  有时需要判断下这个datasource是什么类型的

 if (bindingSourceBase.DataSource is DataSet)
                {
                    ds = (DataSet)bindingSourceBase.DataSource;
                }
                else if (bindingSourceBase.DataSource is DataView)
                {
                    ds = ((DataView)bindingSourceBase.DataSource).Table.DataSet;
                }
                else if (bindingSourceBase.DataSource is DataTable)
                {
                    ds = ((DataTable)bindingSourceBase.DataSource).DataSet;
                }

  

posted @ 2015-03-20 10:32  gclearn  阅读(583)  评论(0编辑  收藏  举报