troubleshooting Question

How to combine date and time in DetailsView

Avatar of cjmackenzie
cjmackenzie asked on
Web Development
8 Comments1 Solution333 ViewsLast Modified:
I have 2 fields in a DetailsView bound to the same date field:

    <asp:DetailsView ID="DetailsView1" runat="server"
        AutoGenerateRows="False"
        DataSourceID="SqlDataSource1"
        DefaultMode="Edit"
        Height="50px"
        >
        <Fields>
            <asp:TemplateField HeaderText="Discharge Date" SortExpression="DischargeDate">
                <EditItemTemplate>
                    <asp:TextBox ID="TheDate" runat="server" MaxLength="8" Text='<%# Bind("ActualDate", "{0:dd/MM/yyyy}") %>'
                        Width="90px"></asp:TextBox>
                    <asp:TextBox ID="TheTime" runat="server" MaxLength="5" Text='<%# Bind("ActualDate", "{0:t}") %>'
                        Width="40px"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>            
        </Fields>
    </asp:DetailsView>

And I have a SqlDataSource that has an update statement:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:bedssqlConnectionString %>"
        SelectCommand="MySelectProcedure"
        SelectCommandType="StoredProcedure"
        UpdateCommand="MyUpdateProcedure"
        UpdateCommandType="StoredProcedure">
        <SelectParameters>
            <asp:QueryStringParameter Name="TheID" QueryStringField="myid" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:QueryStringParameter Name="theid" QueryStringField="myid" />
            <asp:Parameter Name="ActualDate" />
        </UpdateParameters>
    </asp:SqlDataSource>

I am used to ASP.NET setting the value of the update parameter for me when I click on submit. However, because I have split the DateTime into Date and Time, in this case only the time portion is passed back to the database. How can combine the "ActualDate" fields and assign them to the parameter used by the stored procedure?
ASKER CERTIFIED SOLUTION
DarthMod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros