2014-07-23 3 views
0

테이블에 int 값을 저장하려고합니다. 그러나 테이블 데이터 유형을 int32에서 문자열로 변경하면 "암시 적으로 문자열을 int로 변환 할 수 없습니다"라는 메시지가 계속 나타납니다. 이 메시지가 나타납니다 http://postimg.org/image/cv1cc4jkf/full/ 누구든지이 문제를 해결할 수 있습니까? easyScoreLabel, mediumScoreLabel 및 highScoreLabel은 도구 상자에서 웹 응용 프로그램으로 드래그 한 레이블입니다..edmx 테이블에 값을 저장합니다.

protected void myScoresButton_Click(object sender, EventArgs e) 
    { 
     using (projectDBEntities1 dbcontext = new projectDBEntities1()) 
     { 
      message aMessage = new message(); 
     aMessage.userName = nameTextBox.Text; 
     aMessage.highScoreEasy = Int32.Parse(easyScoreLabel.Text); 
     aMessage.highScoreMedium = Int32.Parse(mediumScoreLabel.Text); 
     aMessage.highScoreHard = Int32.Parse(hardScoreLabel.Text); 
     dbcontext.messages.Add(aMessage); 
     dbcontext.SaveChanges(); 

     } 

     GridView1.DataBind(); 
    } 
+0

오류 메시지를 자세히 읽으십시오. 그것은 * 문제가 무엇인지 말합니다. 정확히 어떤 줄을 말하는 겁니까? 줄을 잘못 (잘못)하려고합니까? – user2864740

답변

0

easyScoreLabel.Text는 문자열입니다. 그것을 int로 변환해야합니다.

aMessage.highScoreEasy = Int.Parse(easyScoreLabel.Text); 
aMessage.highScoreMedium = Int.Parse(mediumScoreLabel.Text); 
aMessage.highScoreHard = Int.Parse(hardScoreLabel.Text); 
관련 문제