private void DataBind() { var data = new FieldConfigurationDataModel(); data.FieldConfigurationModeId = GetFCModeId(ddlView.SelectedValue); data.ApplicationId = Convert.ToInt32(ApplicationId); var dt = FieldConfigurationDataManager.CheckDefaultView(data, SessionVariables.RequestProfile); var GroupByField = drpGroupBy.SelectedValue; var tabControl = ApplicationCommon.GetNewDetailTabControl(); var distinctTabNames = (from row in dt.AsEnumerable() orderby row[GroupByField].ToString().Trim() select row[GroupByField].ToString().Trim()) .Distinct(StringComparer.CurrentCultureIgnoreCase).ToList(); foreach (var tabName in distinctTabNames) { var dtGroupingResult = dt.AsEnumerable().Where(t => t[GroupByField].ToString() == tabName).CopyToDataTable(); var totalRecordsInTab = dtGroupingResult.Rows.Count; var groupHeader = tabName; var strHeader = groupHeader + " (" + totalRecordsInTab.ToString(CultureInfo.InvariantCulture) + ")"; if (tabName == "True") { chkListDataWithview.DataSource = dtGroupingResult; chkListDataWithview.DataTextField = "EntityName"; chkListDataWithview.DataValueField = "EntityName"; chkListDataWithview.DataBind(); lblWithView.Text = strHeader; } else { chkListData.DataSource = dtGroupingResult; chkListData.DataTextField = "EntityName"; chkListData.DataValueField = "EntityName"; chkListData.DataBind(); lblView.Text = strHeader; } } }