World Of ιζσεα.

The Dark Time Will Pass

 

Asp.net 2.0 使用FormView + ObjectDataSource 或 SqlDataSource 插入记录后 定位到被插入行

文件下载地址包含sql2k5的mdf 请自行附加:https://files.cnblogs.com/iCaca/SqlOutputParameter.rar

createtable 是sql2k5的语法 2k可能会报错 请自行修改

Tabel User

存储过程

Default.aspx


Default.aspx.cs

最为关键的事件
void SqlDataSource2_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        SqlDataSource2.SelectParameters[0].DefaultValue = e.Command.Parameters[2].Value.ToString();
        FormView1.ChangeMode(FormViewMode.Edit);
        Page.DataBind();
    }

 ObjectDataSource原理相同 插入完后 取e.Command.Parameters 的值

 

posted on 2006-12-17 00:47  Ψιζσεα.  阅读(3599)  评论(5编辑  收藏  举报

导航