/// <summary> /// CustDataGrid 符合条件的列表 /// </summary> /// <param name="grid">grid</param> /// <param name="chk">选取 选中的记录 true 还是未选中的记录 false </param> /// <param name="rows">如果多选,请输入条数</param> /// <returns></returns> public string GetnotSelectStr(CustDataGrid grid, bool chk = true, int rows = 1) { StringBuilder Selected = new StringBuilder(); CustDataGrid cgrid = (CustDataGrid)Page.FindControl("gv_list"); if (cgrid != null) { int count = 0; foreach (DataGridItem item in grid.Items) { CheckBox cb = (CheckBox)item.Cells[0].FindControl("CB_Select"); if (cb != null) { if (chk == cb.Checked) { if (count > rows) { break; } count++; Selected.Append(((HiddenField)item.Cells[0].FindControl("HD_Key")).Value + ","); } } } } return(Selected.ToString().TrimEnd(',')); }
/// <summary> /// 获取拼接IN /// </summary> /// <param name="grid"></param> /// <returns></returns> public string GetWhereStr(CustDataGrid grid) { string strwhere = GetSelectStr(grid); if (strwhere.Length > 0) { return("'" + strwhere.Replace(",", "','") + "'"); } return(strwhere); }
/// <summary> /// CustDataGrid数据列表 获取选中的checkbox /// </summary> /// <returns></returns> public string GetSelectStr(CustDataGrid grid) { StringBuilder Selected = new StringBuilder(); CustDataGrid cgrid = (CustDataGrid)Page.FindControl("gv_list"); if (cgrid != null) { foreach (DataGridItem item in grid.Items) { CheckBox cb = (CheckBox)item.Cells[0].FindControl("CB_Select"); if (cb != null) { if (cb.Checked) { Selected.Append(((HiddenField)item.Cells[0].FindControl("HD_Key")).Value + ","); } } } } return(Selected.ToString().TrimEnd(',')); }
public List <DataGridItem> GetSelectRow(CustDataGrid grid) { List <DataGridItem> lst = new List <DataGridItem>(); CustDataGrid cgrid = (CustDataGrid)Page.FindControl("gv_list"); if (cgrid != null) { foreach (DataGridItem item in grid.Items) { CheckBox cb = (CheckBox)item.Cells[0].FindControl("CB_Select"); if (cb != null) { if (cb.Checked) { lst.Add(item); } } } } return(lst); }