I have the class defined as below
public partial class School
{
public StudentDetails StudentDetails;
private List<string> studentcount;
public List<string> StudentCount
{
get { return studentcount; }
set { studentcount= value; }
}
}
public enum StudentDetails
{
Male,
Female,
}
In my code, I have
if (ctl.Contains("StudentDetails "))
{
ctrlStr = ctl.ToString();
School.StudentDetails = (Request.Form[ctrlStr]);
}
error above is cannot convert string to School.StudentDetails
if(ctl.Contains("StudentCount"))
{
School.Student开发者_开发技巧Count=(Request.Form[ctrlStr]);
}
error here is cannot convert string to List<string>
Can you help me with the syntax
Try
School.StudentDetails = Enum.Parse(typeof(StudentDetails), Request.Form[ctrlStr])
for the first error.
Regarding the second one, why is student count a list of string?
精彩评论