DetailsView插入后进入编辑模式

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int index;
            int.TryParse(Request.QueryString["id"],out index);
            if (index > 0)
            {
                ControlParameter c = new ControlParameter("ID", TypeCode.Int32, "GridView1", "SelectedValue");
                c.DefaultValue = index.ToString();
                this.SqlDataSource2.SelectParameters.Clear();
                this.SqlDataSource2.SelectParameters.Add(c);
                this.DetailsView1.ChangeMode(DetailsViewMode.Edit);
            }
        }
    }
    protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        Response.Redirect("Default2.aspx?id=12");
    }

你可能感兴趣的:(view)