玄铁剑

成功的途径:抄,创造,研究,发明...
posts - 128, comments - 42, trackbacks - 0, articles - 174

导航

<2007年9月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(5)

随笔分类

随笔档案

文章分类

收藏夹

AJAX

asp.net網絡鏈接

Delphi Link

IronPython

Microsoft

Other Blogs

OtherSite

SliverLight

Test

免费asp.net控件

其它链接

搜索

  •  

积分与排名

  • 积分 - 217462
  • 排名 - 26

最新评论

阅读排行榜

评论排行榜

Linq数据操作

Posted on 2008-01-04 21:00 玄铁剑 阅读(363) 评论(0)  编辑 收藏 引用 所属分类: LinQ

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

{

    DataContextDb ctx = new DataContextDb("server=xxx;database=TestDb;uid=xxx;pwd=xxx");           protected void   
    Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             BindView();

        }

    }

    protected void btnOP_Click(object sender, EventArgs e)
    {
        //ctx.Log = Console.Out;

        tbData tbgb = new tbData();
        tbgb .UserName = 'Test001';
        //Add
        ctx.tbData .Add(tbgb );
        //Edit
        ctx.tbData.Remove(tbgb);
        ctx.SubmitChanges();//Add/Edit or Not Add/Edit==>Modify
        BindView();

    }

 

    private void SetBind()
    {

        GridData.DataSource = from gb in ctx.tbData;
        GridData.DataBind();
    }

}

只有注册用户登录后才能发表评论。