GridView 自定义简单操作
来源:互联网 发布:java多线程书籍推荐 编辑:程序博客网 时间:2024/05/18 03:31
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;
public partial class SY16 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
return;
DataBind();
}
protected void GridView_pubs_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int SelectedIndex = e.RowIndex;
string pub_id = GridView_pubs.Rows[SelectedIndex].Cells[1].Text;
BLL.AccessDataBase db = new BLL.AccessDataBase();
db.Delete(pub_id);
DataBind();
Response.Write(SelectedIndex.ToString() + pub_id);
}
protected void Button_query_Click(object sender, EventArgs e)
{
BLL.AccessDataBase db = new BLL.AccessDataBase();
DataSet ds = db.Query(TextBox_query.Text.ToString());
GridView_pubs.DataSource = ds;
GridView_pubs.DataBind();
}
protected void GridView_pubs_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView_pubs.EditIndex = e.NewEditIndex;
DataBind();
}
protected void GridView_pubs_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int EditIndex = e.RowIndex;
Response.Write(EditIndex.ToString());
string pub_id = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[1].Controls[0]).Text;
string pub_name = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[2].Controls[0]).Text;
string city = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[3].Controls[0]).Text;
string state = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[4].Controls[0]).Text;
string country = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[5].Controls[0]).Text;
BLL.AccessDataBase db = new BLL.AccessDataBase();
db.Update(pub_id, pub_name, city, state, country);
GridView_pubs.EditIndex = -1;
DataBind();
}
protected void GridView_pubs_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView_pubs.EditIndex = -1;
DataBind();
}
private void DataBind()
{
BLL.AccessDataBase db = new BLL.AccessDataBase();
DataSet ds = db.ShowData();
GridView_pubs.DataSource = ds;
GridView_pubs.DataBind();
}
}
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;
public partial class SY16 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
return;
DataBind();
}
protected void GridView_pubs_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int SelectedIndex = e.RowIndex;
string pub_id = GridView_pubs.Rows[SelectedIndex].Cells[1].Text;
BLL.AccessDataBase db = new BLL.AccessDataBase();
db.Delete(pub_id);
DataBind();
Response.Write(SelectedIndex.ToString() + pub_id);
}
protected void Button_query_Click(object sender, EventArgs e)
{
BLL.AccessDataBase db = new BLL.AccessDataBase();
DataSet ds = db.Query(TextBox_query.Text.ToString());
GridView_pubs.DataSource = ds;
GridView_pubs.DataBind();
}
protected void GridView_pubs_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView_pubs.EditIndex = e.NewEditIndex;
DataBind();
}
protected void GridView_pubs_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int EditIndex = e.RowIndex;
Response.Write(EditIndex.ToString());
string pub_id = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[1].Controls[0]).Text;
string pub_name = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[2].Controls[0]).Text;
string city = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[3].Controls[0]).Text;
string state = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[4].Controls[0]).Text;
string country = ((TextBox)GridView_pubs.Rows[EditIndex].Cells[5].Controls[0]).Text;
BLL.AccessDataBase db = new BLL.AccessDataBase();
db.Update(pub_id, pub_name, city, state, country);
GridView_pubs.EditIndex = -1;
DataBind();
}
protected void GridView_pubs_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView_pubs.EditIndex = -1;
DataBind();
}
private void DataBind()
{
BLL.AccessDataBase db = new BLL.AccessDataBase();
DataSet ds = db.ShowData();
GridView_pubs.DataSource = ds;
GridView_pubs.DataBind();
}
}
- GridView 自定义简单操作
- 简单的GridView自定义分页
- 用于简单自定义gridview控件
- GridView增删改简单操作
- web控件Gridview简单操作
- DevExpress Gridview数据源更新几个简单操作
- 自定义GridView
- 自定义gridview
- 自定义gridview
- 自定义GridView
- 自定义GridView
- 自定义gridView
- 自定义GridView
- 自定义GridView
- 自定义GridView
- 自定义gridview
- GridView自定义
- GridView操作
- 可可西里伤心地 (郑艳) 2007-7-18
- java的IO包类分层结构
- 那一抹淡淡的汐蓝 (瀑瀑安)
- Util包下常用的数据结构介绍
- vc中Error spawning cl.exe错误的解决方法
- GridView 自定义简单操作
- spring框架不好学呀
- 数据库开发必看 -- 用索引优化SQL,开发优秀的分页存储过程(二)
- ASP.NET 2.0个性化配置(profile)
- Hello , its clocy's blog!
- 终身受用的4个经典故事-转2
- Hello , its clocy's blog!
- Sring中对于产生一个JAVA对象有几种常见的用法
- Oracle Database 9i, 10g闪回版本查询