/*Events*/ //buton click that performs a search based on the Filter criteria protected void btnFilter_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("UserId", typeof(Byte)); dt.Columns.Add("EmployeeId", typeof(Int16)); dt.Columns.Add("Name", typeof(String)); dt.Columns.Add("UserName", typeof(String)); dt.Columns.Add("Status", typeof(String)); dt.Columns.Add("RoleName", typeof(String)); dt.Columns.Add("CreateDate", typeof(DateTime)); dt.Columns.Add("LastActivityDate", typeof(DateTime)); string name = tbName.Text == "" ? null : tbName.Text; string role = ddlRole.SelectedValue == "" ? null : ddlRole.SelectedValue; bool? status = (ddlStatus.SelectedValue == "" ? (bool?)null : (Convert.ToBoolean(ddlStatus.SelectedValue) == true ? true : false)); var model = new EDM.DataSource(); try { var query = model.sp_FilterUsers(role, name, status); var result = query.Distinct().ToList(); if (result.Count > 0) { foreach (var row in result) { dt.LoadDataRow(new object[] { row.UID, row.EmployeeID, row.Name, row.UserName, (row.IsActive == true ? "Active" : "Inactive"), row.RoleName, row.CreateDate, row.LastActivityDate }, false); } } //bind grid if (dt.Rows.Count > 0) { users = dt; } else { users = null; } bindUsers(); lblUsersFound.Text = "Users Found: " + gvUsers.Rows.Count; } catch (System.Exception excec) { MISC.writetoAlertLog(excec.ToString()); ShowMessage("Something went wrong and the search could not be completed. Kindly try again and if the error persists, refer to the error log for details.", MessageType.Error); } }