set object values from form

nobodyno

New Member
I have the following code that sets certain object(CarsCourse) values according to what the user selected in a web form. The code works, but an associate of mine stated that this in the worst possible way of doing this. However, he couldn't offer any suggestions.So is there a better way of accomplishing this?Thanks\[code\] If Not String.IsNullOrEmpty(tbDisplayName.Text) Then CarsCourse.DisplayName = tbDisplayName.Text If Not String.IsNullOrEmpty(tbDescription.Text) Then CarsCourse.Description = tbDescription.Text If Not String.IsNullOrEmpty(tbOfficialStartDate.Text) Then CarsCourse.OfficialStartDate = DateTime.Parse(tbOfficialStartDate.Text) If Not String.IsNullOrEmpty(tbOfficialEndDate.Text) Then CarsCourse.OfficialEndDate = DateTime.Parse(tbOfficialEndDate.Text) If Not String.IsNullOrEmpty(tbBtmDatepicker1.Text) Then CarsCourse.VisibleStartDate = DateTime.Parse(tbBtmDatepicker1.Text) If Not String.IsNullOrEmpty(tbBtmDatepicker2.Text) Then CarsCourse.VisibleEndDate = DateTime.Parse(tbBtmDatepicker2.Text) If Not String.IsNullOrEmpty(ddlDepartment.SelectedValue) Then CarsCourse.SecondarySpecialtyName = ddlDepartment.SelectedValue If Not String.IsNullOrEmpty(ddlOptionType.SelectedValue) Then CarsCourse.OptionType = ddlOptionType.SelectedValue If Not String.IsNullOrEmpty(ddlOfficialName.SelectedValue) Then CarsCourse.OfficialCourseID = Guid.Parse((ddlOfficialName.SelectedValue))\[/code\]
 
Back
Top