Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting a string into date format in the code behind
    primarykey
    data
    text
    <p>I am pulling a date using the Jquery date picker and storing it in a textbox using the following code</p> <p><strong>In the head section</strong> </p> <pre><code>&lt;script src="Scripts/jquery.ui.datepicker.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { $("#&lt;%= TxtDatepicker_start.ClientID %&gt;").datepicker(); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { $("#&lt;%= TxtDatepicker_end.ClientID %&gt;").datepicker(); }); &lt;/script&gt; </code></pre> <p><strong>In the body section</strong> </p> <p> <br /><br /> Start Date: </p> <pre><code> &amp;nbsp;&amp;nbsp;End Date: &lt;asp:TextBox ID="TxtDatepicker_end" runat="server" Width = 125px &gt; &lt;/asp:TextBox&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;asp:Button ID="Button_daterecords" runat="server" Text="Show records" OnClick ="SQLDisplay_Date_records" /&gt;&lt;br /&gt; </code></pre> <p><br /><br /></p> <p>Now the questions is how do I get the value in the text box and convert it to a date (YYYY-MM-DD) format in the code behind ?</p> <p>I tried typecasting it but then I get this error in the code behind </p> <p><strong>cannot implicitly convert system.datetime to system.common.dbparameter</strong></p> <p>The code I am using in the code behind is </p> <pre><code>protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { e.Command.Parameters["@username"].Value = HttpContext.Current.User.Identity.Name; e.Command.Parameters["@Txt_selected_start_date"] = DateTime.Parse(TxtDatepicker_start.Text); } </code></pre> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload