GridView- -事件总结(欧耶)
来源:互联网 发布:photoshop网络课程 编辑:程序博客网 时间:2024/05/21 07:08
--经过潜心单位修炼中有如下杰作慢慢看哇卡卡。
1.点击标题排序 2.分页
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
...{
GridView1.PageIndex = e.NewPageIndex;
BindGrid();
}
...{
GridView1.PageIndex = e.NewPageIndex;
BindGrid();
}
3编辑
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
...{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();
}
...{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();
}
4更新功能
// 更新(- -口水吧功能),设置了OnRowEditing="GridView1_RowEditing"。
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id;
string xiaozhu;
// 下面得到主建
id = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text);
//下面得到更新的内容
fxiaozhu; = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
SqlConnection cnn = new SqlConnection("保密");
try
{
cnn.Open();
//这里写更新
SqlCommand cmd = new SqlCommand("保密")
cmd.ExecuteNonQuery();
}catch()
{
}
finally
{
cnn.Close();
}
GridView1.EditIndex = -1;
BindGrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id;
string xiaozhu;
// 下面得到主建
id = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text);
//下面得到更新的内容
fxiaozhu; = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
SqlConnection cnn = new SqlConnection("保密");
try
{
cnn.Open();
//这里写更新
SqlCommand cmd = new SqlCommand("保密")
cmd.ExecuteNonQuery();
}catch()
{
}
finally
{
cnn.Close();
}
GridView1.EditIndex = -1;
BindGrid();
}
5删除
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
...{
int index = e.RowIndex;
DataKey key = GridView1.DataKeys[index];
int id = Convert.ToInt32(key.Value.ToString());
//省略..因为偶懒的写了~~呵呵
GridView1.EditIndex = -1;
BindGrid();
}
// 为了实现每列都可以自动点击排序,可以设置allowsorting=true,然后设置OnSorting="GridView1_Sorting",或者直接点事件~~别告诉我你不知道在那里~~那来的砖头
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
...{
ViewState["sortexpression"] = e.SortExpression;
//设置viewsate来保存每次排序时的顺序
if (ViewState["sortdirection"] == null)
...{
ViewState["sortdirection"] = "asc";
}
else
...{
if (ViewState["sortdirection"].ToString() == "asc")
...{
ViewState["sortdirection"] = "desc";
}
else
...{
ViewState["sortdirection"] = "asc";
}
}
BindGrid();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
...{
ViewState["sortexpression"] = e.SortExpression;
//设置viewsate来保存每次排序时的顺序
if (ViewState["sortdirection"] == null)
...{
ViewState["sortdirection"] = "asc";
}
else
...{
if (ViewState["sortdirection"].ToString() == "asc")
...{
ViewState["sortdirection"] = "desc";
}
else
...{
ViewState["sortdirection"] = "asc";
}
}
BindGrid();
}
- GridView- -事件总结(欧耶)
- gridview事件总结
- 后台添加gridview事件(鼠标事件,单击双击事件)个人总结
- Asp.Net GridView事件总结(web)
- RecyclerView 使用总结(三):点击事件、GridView等、瀑布流、动态增删
- GridView 事件
- GridView事件
- GridView事件
- GridView 事件
- gridview事件
- GridView 事件
- GridView 事件
- GridView 事件
- GridView 使用方法总结 (一)
- GridView 使用方法总结 (二)
- (转摘)GridView 使用方法总结
- gridview的事件含义(转)
- GridView的databound事件实例(c#)
- ORACLE10G RMAN中run代码块中自动释放通道
- 我们会有我们的天长地久
- 我10年来的学习和生活――应聘华为成功后的总结
- 美人迟暮,英雄末路
- 。颜色 网页色彩转载 白底
- GridView- -事件总结(欧耶)
- 建立企业体系结构的更佳途径
- mysql中数据的导入与导出
- 忘不了的恨~~SqlDataReader
- 如何更好的处理异常
- aspx页面的生命周期
- [整理]各类linux的下载地址[有的可能无效]
- Lucene能做什么
- ASP.NET 应用程序生命周期概述