2017-12-19 31 views
2

동적 asp : table에 필요한 Validator (예제 텍스트 상자)를 추가하고 싶습니다.Dynamic Asp : net 테이블에 필요한 Validator 추가

코드 : 라인 당신이 나를 도와 줄 수 Row.Cells.Add(Cell);

" System.Web.UnhandledException in System.web.dll"

:이 오류를 얻고있다

foreach (KeyValuePair<string, string> o in Collection) 
    { 
     TableRow Row = new TableRow(); 

     TableCell valueCell = new TableCell(); 
     TableCell Cell = new TableCell(); 
     TextBox txtBox = new TextBox(); 
     TextBox txtBox1 = new TextBox(); 


     txtBox1.ID = o.Key + o.Value; 
       if (o.Value.Contains("Mandatory")) 
       { 
        RequiredFieldValidator req = new RequiredFieldValidator(); 

        req.ErrorMessage = "Required"; 
        req.BorderColor = System.Drawing.Color.Red; 
        req.ControlToValidate = txtBox1.ID; 
        req.Enabled = true; 
        req.Display = ValidatorDisplay.Dynamic; 

        Cell.Controls.Add(req); 
       } 

     valueCell.Controls.Add(txtBox1); 
     Row.Cells.Add(valueCell); 
     Row.Cells.Add(Cell); 
     table.Rows.Add(Row); 
} 

그러나?

+1

예외 메시지의 세부 정보를 최소한 입력하십시오. –

+0

이 예외에 대한 세부 정보는 어떻게 얻을 수 있습니까? VS가 표준 Exception 창을 열지 않기 때문입니다. –

+0

빠른 해결책으로,'try/catch' 블록에 코드를 래핑하고'catch' 블록에 중단 점을 넣을 수 있습니다. –

답변

0

Texbox 및 RequireValidatorField가있는 패널에서 문제를 해결합니다.

Panel p = new Panel(); 
    p.Controls.Add(txtBox1); 
    p.Controls.Add(req); 
    valueCell.Controls.Add(p);