倒入 DAL 项目*/ using Model; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = new CategoryDAO().SelectAll();//调用方 法,获取数据源 GridView1.DataBind();//将数据源绑定到 GridView1 控件 /* Response.Write(new SQLHelper().test()); 隐式创建类 (SQLHelper)并对象调用方法:test()*/ } protected void Button1_Click(object sender, EventArgs e) { string caName = TextBox1.Text; string id = TextBox2.Text; category ca=new category( id,caName); bool b = new CategoryDAO().Update(ca); Response.Write(b); GridView1.DataSource = new CategoryDAO().SelectAll();//调用方 法,获取数据源 GridView1.DataBind();//将数据源绑定到 GridView1 控件 } } 源码: category.cs 源码: /* *作者:无声胜有声 * 创建时间:2009-9-28 18:31:02 */ namespace Model { public class category { private string id; public string Id { get { return id; } set { id = value; } } private string name; public string Name { get { return name; }
set { name = value; } } public category(string id, string name) { this.id = id; this.name = name; } } } 源码: categoryDAO.cs 源码: /* *创建人:无声岁月 * 创建时间:2009-09-03 23:20 * 新闻类别表操作类
*
版权所有:无声岁月 */ using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using Model; namespace DAL { ///
/// 新闻类别表操作类 /// public class CategoryDAO { private SQLHelper sqlhelper = null; public CategoryDAO() { sqlhelper = new SQLHelper(); } /