go to a page index corresponding to a specific record in a gridview
<p>Hello I am working on a web page written in <code>ASP</code> and <code>C#</code>, where I can add, <code>edit and delete</code> records from a <code>database</code>. the web page has a <code>grid view</code> that contains a <code>select, edit and delete links</code> in each row, and the rows are ordered by dates. so my question is:
<strong>How can I insert a new record, and automatically go to its corresponding page? (taking for example the grid view page size is 5)</strong></p>

<blockquote>
  <p>this is a part of the grid view</p>
</blockquote>

<pre><code>&lt;asp:GridView ID="grdSchedulerApplications" runat="server" AutoGenerateColumns="False"
                            Visible="false" ShowFooter="True" PageSize="5" DataKeyNames="sa_ID, sa_ApplicationID"
                            AllowPaging="True" OnRowCommand="grdSchedulerApplications_RowCommand"&gt;
                            &lt;Columns&gt;
                                &lt;asp:TemplateField HeaderText="Application" HeaderStyle-HorizontalAlign="Left"&gt;
                                    &lt;EditItemTemplate&gt;
                                        &lt;asp:DropDownList ID="ddlEditSchedulerApplications" runat="server" AutoPostBack="True"
                                            DataTextField="app_Name" DataValueField="app_Id"&gt;
                                        &lt;/asp:DropDownList&gt;
                                    &lt;/EditItemTemplate&gt;
                                    &lt;ItemTemplate&gt;
                                        &lt;%# Eval("Application")%&gt;
                                    &lt;/ItemTemplate&gt;
                                    &lt;FooterTemplate&gt;
                                        &lt;asp:DropDownList ID="ddlSchedulerApplications" runat="server" AutoPostBack="True"
                                            DataTextField="app_Name" DataValueField="app_Id"&gt;
                                        &lt;/asp:DropDownList&gt;
                                    &lt;/FooterTemplate&gt;
                                &lt;/asp:TemplateField&gt;
</code></pre>

<blockquote>
  <p>And then I have the C# code:</p>
</blockquote>

<pre><code>protected void grdSchedulerApplications_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            try
            {
                int saSchdlrID;
                int.TryParse(grdBulkScheduler.SelectedDataKey.Values[0].ToString(), out saSchdlrID);
                DropDownList ddlSchedulerApps = (DropDownList)grdSchedulerApplications.FooterRow.FindControl("ddlSchedulerApplications");

                int appID;
                int.TryParse(ddlSchedulerApps.SelectedValue.ToString(), out appID);

                //calling a method from another class to add/update records into database
                object obj = cData.AddUpdateBulkSchedulerApplications(0, saSchdlrID, appID);

                //query returns the automatically incremented ID of newly created record into obj
                if (obj.ToString() != "0")
                {
                    //do some action
                    //here I need to go to the corresponding page Index
                }
            }
            catch (Exception ex)
            {
                //exception
            }
        }
</code></pre>
