|
我的 代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
//
using DBU;
using Model;
using DAL;
using BLL;
using common;
using System.Web.UI.HtmlControls;
namespace OA.Net.Admin.v.main
{
public partial class hbnaturearea_gvlist : System.Web.UI.Page
{
protected OABll bll = new OABll();
private DBHelper dbh = new DBHelper();
private string tm1 = "";
private string tm2 = "";
private string tm3 = "";
protected void Page_Load(object sender, EventArgs e)
{
if (int.Parse(Session["level"].ToString()) == 1)
{
ttt.Attributes.Add("style", "display:block");
}
if (Request.QueryString["id"] != null)
{
deleteItem(int.Parse(Request.QueryString["id"]));
}
/*if (IsPostBack)
{
if ((t2.Value == "") && (!eachfield.Value.Equals("ALL")))
{
errtishi.Text = "输入有误!如果选择某个字段 ,必须在文本框输入查询条件";
}
else
{
errtishi.Text = "";
}
bind();
}*/
if (!IsPostBack)
{
bind();
}
else
{
bind();
}
//showTable();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
protected void deleteItem(int id)
{
Dnaturearea dpc = new Dnaturearea();
dpc.delete(id);
}
protected void bind()
{
string sql;
tm1 = city.Value;
tm2 = eachfield.Value;
tm3 = t2.Value;
if (tm2 == "ALL")
{
if (tm1 == "ALL")
sql = "select * from hbnaturearea;";
else
sql = "select * from hbnaturearea where city='" + tm1 + "'";
}
else
{
if (tm1 == "ALL")
sql = "select * from hbnaturearea where " + tm2 + "='" + tm3 + "'";
else
sql = "select * from hbnaturearea where city='" + tm1 + "' and " + tm2 + "='" + tm3 + "'";
}
DataTable dt = dbh.search(sql);
//GridView1.DataSource = dt.DefaultView;
GridView1.DataSource = dt;
//GridView1.AllowPaging = true;
//GridView1.PageSize = 100;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
bind();//重新绑定
}
}
}
搞了半天。 晚上在书店看的。 买本书会快很多 。
自己弄了page类 之后自己写的调用 。 用点ajax (回调)
发现2010 delete就是c的指针。 这样c#开发速度完胜java.
|
|