2
ダイナミックasp:テーブルにコントロール(Textboxを例として)にいくつかのバリデータを追加したいと思います。ダイナミックASP:ネットテーブルに必要なバリデータを追加
コード:
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);
}
しかし、私はこのエラーを取得しています:ライン上の
" System.Web.UnhandledException in System.web.dll"
Row.Cells.Add(Cell);
あなたは私を助けることができますか?
少なくとも、例外メッセージの詳細を入力してください。 –
この例外についていくつかの詳細を知ることができますか? VSは標準のExceptionウィンドウを開かないためです。 –
簡単な解決策として、 'try/catch'ブロックにコードをラップし、' catch'ブロックにブレークポイントを置くことができます。 –