private void Bind(int pageIndex) { try { using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString)) { string query = "SELECT [ID], [ToAddress], [LastAttempt], [ToName], [ReadDate], [EmailGroup], [EmailType], [IsSent], [IsRead], [CreateDate], [SentDate], [Subject] FROM [EmailMessage] WHERE 1=1 "; if (TypeDropDown.SelectedValue != "") { query = string.Format("{0} AND([EmailType] = {1})", query, TypeDropDown.SelectedValue); } if (GroupDropDown.SelectedValue != "") { query = string.Format("{0} AND(EmailGroup = '{1}')", query, GroupDropDown.SelectedValue); } if (SentDropDown.SelectedValue != "") { query = string.Format("{0} AND([IsSent] = {1})", query, SentDropDown.SelectedValue); } if (ReadDropDown.SelectedValue != "") { query = string.Format("{0} AND([IsRead] = {1})", query, ReadDropDown.SelectedValue); } query = string.Format("{0} ORDER BY CreateDate desc ", query); EmailGrid.DataSource = db.ExecuteQuery <EmailMessage>(query, new object[] { }).ToList <EmailMessage>(); EmailGrid.PageIndex = pageIndex; EmailGrid.DataBind(); } } catch (Exception ex) { Trace.Write("Unable to fetch email records."); Trace.Write(ex.Message); Trace.Write(ex.StackTrace); } }
private void Bind(int pageIndex) { try { using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString)) { string query = "SELECT ID, Email, Createdate, Newsletter, UserType, MemberName, Status, Password " + " FROM Member AS M WHERE UserType <> 1 "; if (MemberTypeDropDown.SelectedValue != "") { query = string.Format("{0} AND(UserType = {1})", query, MemberTypeDropDown.SelectedValue); } if (StatusDropDown.SelectedValue != "") { query = string.Format("{0} AND(Status = {1})", query, StatusDropDown.SelectedValue); } if (SubscribeList.SelectedValue != "") { query = string.Format("{0} AND(Newsletter = {1})", query, SubscribeList.SelectedValue); } query = string.Format("{0} ORDER BY CreateDate desc ", query); MemberGridView.DataSource = db.ExecuteQuery <Member>(query, new object[] { }).ToList <Member>(); MemberGridView.PageIndex = pageIndex; MemberGridView.DataBind(); } } catch (Exception ex) { Trace.Write("Unable to fetch member records."); Trace.Write(ex.Message); Trace.Write(ex.StackTrace); } }