青海龙8国际乐建设、网络推广最好的公司--您身边的龙8国际乐建设专家,马上拿起电话,联系我们:0971-8235355   
青海西宁龙8国际乐建设、龙8国际乐制作公司-西宁威势电子信息服务有限公司
 
西宁威势最新龙8国际乐制做案例展示
Lastest Project
 
当前位置为:首页 >> .NET编程 >> 正文  
龙8国际乐_龙8国际娱乐电脑版_龙8国际娱城手机版

文章来源: 西宁威势电子信息服务有限公司     发布时间:2010-9-29    浏览次数:2190   

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
public partial class qhwins_WebClass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGRD();
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindGRD();
    }
    protected void BindGRD()
    {
        DataSet ds = qhwins.db.dataSet("select * from qhwins_Class where ParentClassID='0'");
        this.GridView1.DataSource = ds;
        this.GridView1.DataKeyNames = new String[] { "ClassID" };
        this.GridView1.DataBind();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            using (OleDbConnection conn = qhwins.db.GetConnection())
            {
                conn.Open();
                string ClassID = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.Trim();
                string ClassName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim();
                OleDbCommand cmd = new OleDbCommand("update qhwins_class set ClassName=@ClassName where ClassID=@ClassID", conn);
                OleDbParameter p1 = new OleDbParameter("@ClassName", OleDbType.VarChar, 100);
                p1.Value = ClassName;
                cmd.Parameters.Add(p1);
                OleDbParameter p2 = new OleDbParameter("@ClassID",OleDbType.VarChar,22);
                p2.Value = ClassID;
                cmd.Parameters.Add(p2);
                cmd.ExecuteNonQuery();
                GridView1.EditIndex = -1;
            }
        }
        catch(Exception ex)
        {
            throw new Exception(ex.Message);
        }
        BindGRD();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            using (OleDbConnection conn = qhwins.db.GetConnection())
            {
                conn.Open();
                OleDbCommand cmd = new OleDbCommand("delete * from qhwins_class where ClassID='"+ GridView1.DataKeys[e.RowIndex].Value.ToString()+"'", conn);
                cmd.ExecuteNonQuery();
                GridView1.EditIndex = -1;
                conn.Close();
                BindGRD();
            }
        }
        catch
        {

        }
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
      GridView1.EditIndex = -1;
       BindGRD();
    }
}


评论列表
正在加载评论……
  
评论   
呢  称:
验证码:
若看不清请点击更换!
内  容:
 
 
  在线洽谈咨询:
点击这里,在线洽谈   点击这里,在线洽谈   点击这里,在线洽谈
乘车路线    汇款方式   加盟合作  人才招聘
 
公司地址:青海省西宁市西关大街73号(三二四部队招行所四楼)     青ICP备13000578号-1 公安机关备案号:63010402000123    
QQ:147399120    mail:lostlove000@163.com    电话: 13897410341    邮编:810000
© Copyright( 2008-2009) QhWins.Com All Rights Reserved    版权所有:西宁威势电子信息服务有限公司 未经书面制授权,请勿随意转载!