Hi Andrew,
1. You can do this by checking the QueryString when the page is first
loaded (non-postback):
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sid = Request.QueryString["ID"];
if (sid != null)
{
FormView1.DefaultMode = FormViewMode.Edit;
}
else
{
FormView1.DefaultMode = FormViewMode.Insert;
}
}
}
2. You can handle this in the Inserted event of ObjectDataSource and do a
redirect to current page with ID appended to the QueryString:
protected void ObjectDataSource1_Inserted(object sender,
ObjectDataSourceStatusEventArgs e)
{
int id = (int)e.ReturnValue;
Response.Redirect(Request.Url.ToString() + "?ID=" + id.ToString(),
true);
}
3. You can always provide the SelectPrarameters ID in the Selecting event
of ObjectDataSource:
protected void ObjectDataSource1_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["id"] = Request.QueryString["ID"];
}
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang (, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
|