Jump to content

arpitsharma

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by arpitsharma

  1. i have a form in which i have a field date of birth , and a textbox to fill date of birth , when a person fills his date of birth like 01/01/1990 , then it will be saved into database , and when i retrieve this date form database then this comes 01/01/1990 12:00 AM , i want only date part from it.

    This is my form to fillup date of birth

    form.aspx

     <tr>
          <td width="30%">
             Date of Birth
              <br />
          </td>   <td style="width: 1px">
           :<asp:TextBox ID="txtDateofBirth" runat="server" placeholder="dd/mm/yyyy"></asp:TextBox>
           </td> <td class="td2">                                                                                     
                                                                     
                                                                                                   
              </td>
              </tr>

    this is code for form.aspx.cs

     SqlCommand cmd = new SqlCommand("insert into ApplicantForm(NameofApplicant,  dateofbirth)" +
                                                                    "values( @NameofApplicant, convert(Datetime, @dateofBirth, 103)", con);
    cmd.Parameters.AddWithValue("@dateofBirth",txtDateofBirth.Text);

    this is code for print of this date of birth

    print.aspx

       <asp:Label ID="txtDOB" runat="server"  ></asp:Label>

    this is code print.aspx.cs

      SqlCommand cmd = new SqlCommand("Select * from ApplicantForm Where ApplicantId=" + ((Request.QueryString["ApplicantId"])) + "", con);
     dr = cmd.ExecuteReader();
     
    txtDOB.Text = dr["dob"].ToString();

     

×
×
  • Create New...