I am working on a web form that accesses some of the cells from a gridview on the previous page. One of the cells (First) that I am getting the value from may or may not contain some text.
I need to pass this text (if there is any) as a variable to my stored procedure, which does a select statement the FormView that appears on the page.
Here is my SqlDataSource select parameters:
<SelectParameters>
<asp:Parameter Name="IDNumber" Type="Int32" />
<asp:Parameter Name="First" Type="String" />
</SelectParameters>
Here is how I am accessing the GridView cells from the previous page for my select parameters:
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
e.Command.Parameters("@IDNumber").Value = PreviousPage.AppointmentID
If PreviousPage.First Is Nothing Then
e.Command.Parameters("@First").Value = System.DBNull.Value
Else
e.Command.Parameters("@First").Value = PreviousPage.First
End If
End Sub
Here is an example of how I am accessing the GridView cells on the previous page:
Public ReadOnly Property First() As String
Get
Return GridView1.SelectedRow.Cells(4).Text
End Get
End Property
So here is my problem: The stored procedure works great when I have a value for @First (ie. the cell in the gridview wasn't empty), but when the cell in the gridview is empty I have no value for @First and my stored prcedure doesn't work. So how can I convert the empty string to a null value that I can pass to my stored procedure? As you can see from my above code I am trying to account for the possibility of the gridview cell being empty, but so far it is not working.
Thanks for the words of wisdom.