using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class adminuser : System.Web.UI.Page { OleDbConnection conn; string sql; protected void Page_Load(object sender, EventArgs e) { if (Session["Userid"] == "" || Session["Userid"] == null) { Response.Redirect("index.aspx"); } conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Domains\nid.edu\db\database.mdb;Persist Security Info=True"); if (!IsPostBack) { fillCombo(); } } protected void fillCombo() { conn.Open(); OleDbCommand cmd = new OleDbCommand("select distinct discipline from MemberMaster", conn); OleDbDataAdapter dap = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); dap.Fill(dt); dropDiscipline.DataSource = dt; dropDiscipline.DataBind(); conn.Close(); } protected void btnSearch_Click(object sender, EventArgs e) { sql = ""; if (txtFirstName.Text != "") { sql = "First_name='" + txtFirstName.Text + "'"; } if (txtLastName.Text != "") { if (sql != "") { sql = sql + " or " + "Last_name='" + txtLastName.Text + "'"; } else { sql = "Last_name='" + txtLastName.Text + "'"; } } if (txtYearGraduation.Text != "") { if (sql != "") { sql = sql + " or " + "YR_SPLSN='" + txtYearGraduation.Text + "'"; } else { sql = "YR_SPLSN='" + txtYearGraduation.Text + "'"; } } if (dropDiscipline.SelectedItem.Text != "") { if (sql != "") { sql = sql + " or " + "Discipline='" + dropDiscipline.SelectedItem.Text + "'"; } else { sql = "Discipline='" + dropDiscipline.SelectedItem.Text + "'"; } } OleDbCommand cmd2 = new OleDbCommand("select * from MemberMaster where " + sql + "", conn); OleDbDataAdapter dap2 = new OleDbDataAdapter(cmd2); DataTable dt2 = new DataTable(); int count = dap2.Fill(dt2); gridSearch.DataSource = dt2; gridSearch.DataBind(); } protected void lnkSelect_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; Response.Redirect(lb.CommandName); //Server.Transfer(lb.CommandName); } }