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 3: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
0 OriginalGriff 245
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100