| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 924 人关注过本帖
标题:求助GridView不能更新
只看楼主 加入收藏
yph1331
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-11-6
收藏
 问题点数:0 回复次数:0 
求助GridView不能更新
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;
using System.Data.SqlClient;
using weblibrary.data;

public partial class _Default : System.Web.UI.Page
{
    private SqlDataAdapter da;
    private DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        getInfo();
      
    }

    private void getInfo()
    {
        string str = "Data Source = .;Initial Catalog = library; User Id = sa;Password = 123";
        string sql = "select * from LB_FLXX";
        SqlConnection conn = new SqlConnection(str);
        da = new SqlDataAdapter(sql, conn);
        da.Fill(ds, "t");
        GridView1.DataSource = ds.Tables["t"];
        GridView1.DataBind();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        getInfo();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        da.Update(ds, "t");
        GridView1.EditIndex = -1;
        getInfo();
    }

    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        getInfo();
    }
}
搜索更多相关主题的帖子: GridView 
2008-11-06 14:11
快速回复:求助GridView不能更新
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021787 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved