Member
136 Points
583 Posts
Sep 01, 2016 05:26 PM|ldoodle|LINK
Hey,
Is there a better of doing this (the 4 integers):
try { using (Connection = new SqlConnection(BasePage.SqlConnection)) using (Command = new SqlCommand("genSelUsers", Connection)) { Command.CommandType = CommandType.StoredProcedure; Command.Parameters.AddWithValue("@AbsenceOnly", "false"); using (SqlDataAdapter da = new SqlDataAdapter(Command)) { ds = new DataSet(); da.Fill(ds); ds.Tables[0].TableName = "Users"; ds.Tables[1].TableName = "Absences"; ds.Tables[2].TableName = "Clockings"; ds.Relations.Add("Users_Absences", ds.Tables["Users"].Columns["User_Number"], ds.Tables["Absences"].Columns["EMP_Number"], false); // ds.Relations[0].Nested = true; ds.Relations.Add("Users_Clockings", ds.Tables["Users"].Columns["User_Number"], ds.Tables["Clockings"].Columns["EMP_Number"], false); // ds.Relations[1].Nested = true; } } int StaffTotal = ds.Tables["Users"].Select().Length; int StaffIn = ds.Tables["Users"].Select("status = 'in'").Length; int StaffOut = ds.Tables["Users"].Select("status = 'out'").Length; int StaffFilter = ds.Tables["Users"].Select(BasePage.SearchExpression(SearchValue, "Staff")).Length; DataView Staff_View = ds.Tables["Users"].DefaultView; Staff_View.RowFilter = BasePage.SearchExpression(SearchValue, "Staff"); Staff_View.Sort = SortExpression; Staff_Repeater.DataSource = Staff_View; Staff_Repeater.DataBind(); Literal StaffTotal_Literal = (Literal)Staff_Repeater.Controls[0].FindControl("StaffTotal_Literal"); StaffTotal_Literal.Text = StaffTotal.ToString(); Literal StaffIn_Literal = (Literal)Staff_Repeater.Controls[0].FindControl("StaffIn_Literal"); StaffIn_Literal.Text = StaffIn.ToString(); Literal StaffOut_Literal = (Literal)Staff_Repeater.Controls[0].FindControl("StaffOut_Literal"); StaffOut_Literal.Text = StaffOut.ToString(); Literal StaffFilter_Literal = (Literal)Staff_Repeater.Controls[0].FindControl("StaffFilter_Literal"); if (String.IsNullOrEmpty(BasePage.SearchExpression(SearchValue, "Staff"))) { StaffFilter_Literal.Text = "not applied"; } else { StaffFilter_Literal.Text = StaffFilter.ToString(); }
Thanks
Member
136 Points
583 Posts
Count items in DataTable/DataView
Sep 01, 2016 05:26 PM|ldoodle|LINK
Hey,
Is there a better of doing this (the 4 integers):
Thanks