Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
objStudent.UserName = GetUserName();
          objStudent.Password = _objIBALCommonFunction.GenerateRandomString(8);//_objIBALCommonFunction.Encrypt(_objIBALCommonFunction.GenerateRandomString(8));
          objStudent.FirstName = txtFirstName.Text.ToString().Trim().Replace("'", "");
          objStudent.RollNo = txtRollNo.Text.ToString().Trim().Replace("'", "");
          objStudent.LastName = txtLastName.Text.ToString().Trim().Replace("'", "");
          if (rbGenderFemale.Checked)
          {
              gen = 'F';
          }
          else
          {
              gen = 'M';
          }
          objStudent.Gender = gen.ToString();
          objStudent.Email = txtEmail.Text.ToString().Trim().Replace("'", "");
          objStudent.Phone = txtPhone.Text.ToString().Trim().Replace("'", "");
          objStudent.Mobile = txtMobile.Text.ToString().Trim().Replace("'", "");
          objStudent.Address = txtAddress.Text.ToString().Trim().Replace("'", "");
          try
          {
          //objStudent.DOB = txtDOB.Text;
            objStudent.DOB = DateTime.ParseExact(txtDOB.Text, "dd/MM/yyyy", null).ToString();
            //objStudent.DOB = txtDOB.Text.ToString().Trim().Replace("'", "");
          }
          catch (Exception ex)
          {
              lblError.Text = "Date of Birth not in proper format !";
              return;
          }
          objStudent.BloodGroup = txtBloodGroup.Text.ToString().Trim().Replace("'", "");
          try
          {
            objStudent.AdmissionDate = DateTime.ParseExact(txtAdmissionDate.Text, "dd/MM/yyyy", null).ToString();
            // objStudent.AdmissionDate = txtAdmissionDate.Text.ToString().Trim().Replace("'", "");
          }
          catch (Exception ex)
          {
              lblError.Text = "Admission Date not in proper format !";
              return;
          }
 
          objStudent.CityId = Convert.ToInt32(ddlCity.SelectedValue);
          objStudent.StateId = Convert.ToInt32(ddlState.SelectedValue);
          objStudent.Pincode = txtPincode.Text.ToString().Trim().Replace("'", "");
 
          if (txtPhoto.PostedFile.ContentLength > 0)
          {
              string fullPath = Server.MapPath("Image/" + objStudent.UserName + Path.GetExtension(txtPhoto.PostedFile.FileName));
              objStudent.ImagePath = System.Configuration.ConfigurationManager.AppSettings["ImageUrl"].ToString() + "Module-Customer/Image/" + objStudent.UserName + Path.GetExtension(txtPhoto.PostedFile.FileName);
              txtPhoto.PostedFile.SaveAs(fullPath);
          }
          else
          {
              if (gen == 'M') { objStudent.ImagePath = System.Configuration.ConfigurationManager.AppSettings["ImageUrl"].ToString() + "Module-Customer/Image/male_user.png"; }
              else { objStudent.ImagePath = System.Configuration.ConfigurationManager.AppSettings["ImageUrl"].ToString() + "Module-Customer/Image/female_user.png"; }
          }
          objStudent.Theme = ddlTheme.SelectedValue;
          objStudent.Menu = ddlMenu.SelectedValue;
          objStudent.Description = txtDescription.Text.ToString().Trim().Replace("'", "");
          objStudent.InstituteName = txtInstituteName.Text.ToString().Trim().Replace("'", "");
          objStudent.ClassName = txtClassName.Text.ToString().Trim().Replace("'", "");
          objStudent.ObtainedMarks = txtObtainedMarks.Text.ToString().Trim().Replace("'", "");
          objStudent.YearPassing = ddlYearPassing.SelectedValue;
          objStudent.IsActive = 1;
          objStudent.IsDeleted = 0;
          objStudent.BAId = Convert.ToInt32(Session["BAId"].ToString());
Posted 8-Dec-12 2:33am
Comments
VishwaKL at 10-Dec-12 5:00am
   
Can you spot which line giving error

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

May be your data type is datetime of DOB. So, you have to supply datetime format data.
 
you can change this line:
 
try
        {
        //objStudent.DOB = txtDOB.Text;
            objStudent.DOB=Convert.ToDateTime(DateTime.Parse("13/1/2012").ToString("dd/MM/yyyy"));
          //objStudent.DOB = txtDOB.Text.ToString().Trim().Replace("'", "");
        }
        catch (Exception ex)
        {
            lblError.Text = "Date of Birth not in proper format !";
            return;
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 457
1 OriginalGriff 430
2 Shai Vashdi 240
3 Emre Ataseven 165
4 Peter Leow 146
0 Sergey Alexandrovich Kryukov 8,944
1 OriginalGriff 5,280
2 Peter Leow 3,985
3 Maciej Los 3,535
4 Abhinav S 3,218


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid