MdotButler
Programmer
I have a formview which is tied to a ObjectDataSource. The datasource select is based on a querystring ("Edit"). From another page I issue command "A" as illustrated below. I also wish to access the same form via a menu passing a value (Zero as illustrated in "B" below) that allows the form to open in insert mode.
When working with a record that already exists I have no problems and am able to enter edit multiple times against record 123 as illustrated in example "A" above. The problem comes when accessed via a menu passing 0 to add a new record. I am able to identify this in the "Page_Load" as illustrated next.
The problem occurs once I have added the record and saved it. The QueryString still exists and is then picked up in the "Page_Load" and enters insert mode again.
There has to be a better way. In case "A" I am coming from a GridView which is the result of a "Find" which works fine. In case "B", how would I obtain the new record key after insertion and reissue the access with the correct querystring? Is there a better way?
TIA
Mark
P.S. I also do not like using querystring as it gives the user a chance to modify it.
Code:
A) Response.Redirect("EditRecord_E.aspx?Edit=123")
B) Response.Redirect("EditRecord_E.aspx?Edit=0")
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (IsPostBack) Then
If FormView1.DefaultMode = FormViewMode.Insert Then
FormView1.DefaultMode = FormViewMode.ReadOnly
End If
Else
If Request.QueryString("Edit") = "Add" Then
FormView1.DefaultMode = FormViewMode.Insert
End If
End If
End Sub
There has to be a better way. In case "A" I am coming from a GridView which is the result of a "Find" which works fine. In case "B", how would I obtain the new record key after insertion and reissue the access with the correct querystring? Is there a better way?
TIA
Mark
P.S. I also do not like using querystring as it gives the user a chance to modify it.