vs2008 web express: load page on post back with inserted records
<p>After I insert a record on my page MyRecord.aspx, I load the data on page as follows:</p>

<pre><code>   protected void sqlDSMyProfile_OnInserted(object sender, SqlDataSourceStatusEventArgs e)
{
    int i = Int32.Parse((e.Command.Parameters["@RecordID"].Value.ToString()));
    string url = "http://localhost:1097/MyWebSite/MyProfile.aspx?RecordID=" + i.ToString();
    Response.Redirect(url);
}
</code></pre>

<p>The above approach is silly but then how do I load the page on post back with the latest inserted record. RecordID is the id of the latest inserted record.</p>

<p>This page is driven by SQLDataSource and DetailViewControl. In SQLDataSource, I load it as follows:</p>

<pre><code>    &lt;SelectParameters&gt;
        &lt;asp:QueryStringParameter 
            DefaultValue="1" Name="RecordID" 
            QueryStringField="RecordID" Type="Int32" 
            /&gt;
    &lt;/SelectParameters&gt;
</code></pre>

<p>entire markup of sqldatasource is as follows:</p>

<pre><code>&lt;asp:SqlDataSource ID="sqlDSMyRecord" runat="server" 
    ConnectionString="&lt;%$ ConnectionStrings:matrim_devConnectionString %&gt;" 
    InsertCommand="RecordDetail_i"
    InsertCommandType=StoredProcedure
    UpdateCommand= "RecordDetail_u"
    UpdateCommandType=StoredProcedure
    SelectCommand="RecordDetail"
    SelectCommandType="StoredProcedure"
    OnInserted="sqlDSMyRecord_OnInserted"
    &gt;
    &lt;SelectParameters&gt;

        &lt;asp:QueryStringParameter 
            DefaultValue="1" Name="RecordID" 
            QueryStringField="RecordID" Type="Int32" 
            /&gt;
    &lt;/SelectParameters&gt;
    &lt;DeleteParameters&gt;
        &lt;asp:Parameter Name="RecordID" Type="Int32" /&gt;
    &lt;/DeleteParameters&gt;
    &lt;InsertParameters&gt;
        &lt;asp:Parameter Name="RecordName" Type="String" /&gt;
        &lt;asp:Parameter Name="City" Type="String" /&gt;
        &lt;asp:Parameter Name="State" Type="String" /&gt;
        &lt;asp:Parameter Name="RecordDetails" Type="String" /&gt;
        &lt;asp:Parameter Name="CountryID" Type="Int32" /&gt;
        &lt;asp:Parameter Name="RecordID" Type="Int32" Direction=Output /&gt;
    &lt;/InsertParameters&gt;
    &lt;UpdateParameters&gt;
        &lt;asp:Parameter Name="RecordName" Type="String" /&gt;
        &lt;asp:Parameter Name="City" Type="String" /&gt;
        &lt;asp:Parameter Name="State" Type="String" /&gt;
        &lt;asp:Parameter Name="RecordDetails" Type="String" /&gt;
        &lt;asp:Parameter Name="CountryID" Type="Int32" /&gt;
        &lt;asp:Parameter Name="RecordID" Type="Int32" /&gt;
    &lt;/UpdateParameters&gt;
&lt;/asp:SqlDataSource&gt;
</code></pre>

<p>Please help..</p>
