I have a funny situation where I am trying to pass a date (formatted as a String in yyyy-MM-dd format [i.e. 2013-08-01]) to an SQL stored procedure within an asp.net webpage. I have the stored procedure set up, but now I have to pass the date as a parameter. The date I need is located in a separate SQL table, so I created a TextBox (we'll call it endDATE) that provides the date I will need AND that I can hide to make it invisible on the webpage.
The problem is that the TextBox is contained within a DetailsView, so I can't seem to access it for the stored procedure.
I'm thinking I should try to pass the String from the TextBox using VB code to the stored procedure. How do I do this?
Code of TextBox:
<asp:DetailsView ID="LatestDate" DataSourceID="SqlDataSource6" runat="server" AutoGenerateRows="false"
AutoGenerateColumns="False" BorderStyle="None" GridLines="None">
<Fields>
<asp:BoundField DataField="MostRecent" HeaderText="" ReadOnly="True" ShowHeader="False"
DataFormatString="Daily: {0:M/d/yyyy}" ItemStyle-CssClass="boldbig" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox runat="server" ID="endDATE" Visible="false" Text='<%# Eval("MostRecent","{0:yyyy-MM-dd}") %>' />
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
Code of Stored Procedure [date1 is the parameter I am trying to provide]:
<asp:SqlDataSource ID="SqlDataSource7" runat="server"
ConnectionString="<%$ConnectionStrings:ConnectionString3 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>"
SelectCommand="dbo.TheMgr_Total"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter name="MgrName" DbType="String" QueryStringField="id" />
<asp:Parameter Name="date1" DbType="String" DefaultValue="2013-08-08" />
</SelectParameters>
</asp:SqlDataSource>
Update: Steve's solution looks good to me, but I was never able to get it to work. My project changed directions, so I am no longer working on this particular problem.
sql-servertag to make this clear. If not: what database system is this for?