文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > GridView用法
侵权投诉

GridView用法

GridView用法

2007-02-03 08:43:24| 分类: asp.net |字号 订阅

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

this.BindToGridView();

}

}

//定义绑定

private void BindToGridView()

{

SqlConnection conn = DB.Createconn();

conn.Open();

SqlDataAdapter sda = new SqlDataAdapter();

sda.SelectCommand = new SqlCommand("select * from newstype order by typeID", conn);

DataSet ds = new DataSet();

sda.Fill(ds, "newstype");

this.GridView1.DataKeyNames = new string[] { "typeid" }; this.GridView1.DataSource = ds.Tables["newstype"]; this.GridView1.DataBind();

conn.Close();

}

//添加记录

protected void btnAdd_Click(object sender, EventArgs e) {

SqlConnection conn = DB.Createconn();

conn.Open();

SqlCommand cmd = new SqlCommand("insert into newsType(typeName) values('"+this.txtTypeName.Text+"')",conn);

cmd.ExecuteNonQuery();

conn.Close();

this.txtTypeName.Text = "";

this.BindToGridView();

}

//分页

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

第1页

你可能喜欢

热门文档

相关文档

  • Gridview用法(个人总结)20120803

    Gridview用法(个人总结)20120803_计算机软件及应用_IT/计算机_专业资料。gridview的简单使用(个人总结)Gridview 的一些操作: 1、添加删除列: 直接使用 Gridview 的...

  • gridview的用法

    (ds, "tb_Card"); GridView1.DataSource = ds; GridView1.DataBind(); } protected void CheckBox2_CheckedChanged(object sender, EventArgs e) { for (int...

  • GridView用法

    (转)GridView _ 伟 伟

  • GridView使用方法大全

    GridView 使用方法大全 GridView 无代码分页排序 GridView 选中,编辑,取消,删除 选中,编辑,取消, GridView 正反双向排序 GridView 和下拉菜单 DropDownList 结合 ...

  • 详解GridView 使用方法

    详解GridView 使用方法_资格考试/认证_教育专区。详解 GridView 使用方法GridView 使用方法总结 1.GridView 无代码分页排序: 1.AllowSorting 设为 True,aspx 代码中...

  • ASPXGridView用法

    ASPXGridView用法_工学_高等教育_教育专区。ASPXGridView详解(上) 一。ASPXGridView外观显示属性: Caption---列的标题( KeyFieldName---数据库字段 SEOFriendlyASPX...

  • gridview用法大全

    gridview 事件学习: 一、事件说明 1.1RowCommand 在 GridView 控件中单击某个按钮时发生。此事件通常用于在该控件中单击某个按钮时执行某项任务。 1....

  • gridView使用方法

    gridView使用方法_IT/计算机_专业资料。gridViewGridView 72 般绝技 快速预览: GridView无代码分页排序 GridView选中,编辑,取消,删除 GridView正反双向排序 Grid...

  • GridView控件用法

    <GridView xmlns:android="http://schemas.android.com/apk/res/android" 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. /> android:id="@+id/gridview" ...

  • GridView用法大合集

    46 3 GridView 用法集锦 1 数据绑定并实现分页功能: 数据绑定并实现分页功能: 1.1 GridView 控件数据绑定与分页技术有关属性与事件: 控件数据绑定与分页技术有关...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email