开发者

Get the value of entered by the user in the class property

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜