SessionParameter and Update Query with SqlDataSource
<p>I have an UpdateQuery within my SQLDataSource, where the parameter is being supplied from SessionParameter. The value for the SessionParameter is being set from my codebehind via a button click on a gridview. </p>

<p>The objective is when the user clicks a button on the gridview it updates the database via the gridview. The problem I am getting is that the update query is not being executed as I am not seeing the row updated with the new value. The debugging I have done has shown that I am getting the value I want on the row that is being selected, and the session is being set.</p>

<p>Here is the relevant code snippet:</p>

<pre><code>&lt;asp:SqlDataSource ID="JobNameDatasource" runat="server"
ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;"

SelectCommand="SELECT [JobName], [ChangedDate], [AdHocFlg] FROM [t_Config_iFace_Execution]"
UpdateCommand="UPDATE [t_Config_iFace_Execution] SET [RunJob] = 1 WHERE [JobName] =  @JobName"&gt;
&lt;UpdateParameters&gt;
&lt;asp:SessionParameter Name="JobName" SessionField="JobName"/&gt;
&lt;/UpdateParameters&gt;
&lt;/asp:SqlDataSource&gt;

Protected Sub RunJob_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
   If e.CommandName = "UpdateJob" Then
     Dim btnRunJob As Button = TryCast(e.CommandSource, Button)
     Dim gvr As GridViewRow = TryCast(btnRunJob.NamingContainer, GridViewRow)
     Dim rowIndex As Integer = gvr.RowIndex
     Dim Name As String = DirectCast(GridView1.DataKeys(rowIndex).Values("JobName"), String)
     Session.Add("JobName", Name)
     Label1.Text = Session("JobName")
   End If
End Sub
</code></pre>

<p>Any ideas why it isn't working? I thought this would be straightforward unless I am missing something obvious?</p>
