VS 2005 sqldatasource set parameter value to value of another parameter
I'm using a VS2005 webform with a detailsview which only allows inserting a new record. The form is used to log visitor requests. Visitors may visit for only one day or multiple days.
In the instance of multiple days, the requestor enters the arrival and the end dates of the visit (visitDate and visitEndDate are the field names.)
If the visit is only one day, I would like to update the visit date to automatically be the same as the arrival date.
I'm sure there's a way to do it, I just haven't figured it out yet.
I tried this but it doesn't work. I don't get an error, it just doesn't work:
If e.Command.Parameters("@visitEndDate") Is Nothing Then e.Command.Parameters("@visitEndDate").Value = e.Command.Parameters("@visitDate").Value End If
I tried it without the "@" and it errors out with this message "A SqlParameter with ParameterName 'visitEndDate' is not contained by the SqlParameter Collection"
The ParameterName is "@visitEndDate" so wouldn't I need the "@?"
What method are you trying to update the parameter in?
Can you post the aspx markup code for the sqldatasource
0
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
How are you binding your form field values to the parameters, are you also doing this manually in the sqldatasource_inserting method or declaratively in the form.
Have you tried looking at the value of e.Command.Parameters("@visitEndDate") at runtime when debugging, maybe it is passing an empty string rather than being null.
So you would need to do something like :
If e.Command.Parameters("@visitEndDate") Is Nothing Or e.Command.Parameters("@visitEndDate").Value = String.Empty Then e.Command.Parameters("@visitEndDate").Value = e.Command.Parameters("@visitDate").Value End If
Open in new window