日期:2014-05-17 浏览次数:20433 次
protected void GridViewBind(string condition) { string sql = "select *from teacher"; Common comn = new Common(); DataSet ds = comn.GetDataSet(sql); #region 实现单击列标题排序要用到的代码 DataView myView = ds.Tables[0].DefaultView; string sort = (string)ViewState["SortOrder"] + " " + (string)ViewState["OrderDire"]; myView.Sort = sort; #endregion GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); }
protected void BtnConfirm1_Click(object sender, EventArgs e) { string sql = "select * from teacher where 1=0 "; string sqlCondition = string.Empty; if (txtTeacherNum.Text.Trim() != "") { sqlCondition += "and tid like '" + txtTeacherNum.Text.Trim() + "%' "; } if (txtTeacherName.Text.Trim() != "") { sqlCondition += "and tname = '%" + txtTeacherName.Text.ToString() + "%' "; } if (txtSubject.Text.Trim() != "") { sqlCondition += "and subject = '%" + txtSubject.Text.ToString() + "%' "; } sql += sqlCondition; Common comm = new Common(); comm.ExecuteNonQuery(sql); GridView1.EditIndex = -1; // 这里怎么绑定呀? }