私は前にこれに取り組みました。これには2つのテーブルを使用しました。
KeyField_Master:フィールド名、タイプ、および必須かどうか。
と
KeyField_Details :(値と説明)の観点からカスタムフィールドの値を格納します。
Page_Loadイベントを使用して、そのフィールドを作成します
if (keyField_type == "T") // Textbox
{
txtBox.Attributes.Add("Type", "T"); // type of field for validation
txtBox.Attributes.Add("IsKeyField", "Y"); // to mark it as a custom field
if (isMandatory == "Y")
txtBox.Attributes.Add("IsMandatory", "Y"); // is it mandatory
// you could set layout of these controls using HTML Tables or any other way you prefer.
htmlCell.Controls.Add(txtBox);
htmlRow.Cells.Add(htmlCell);
tbHTML.Rows.Insert(2, htmlRow);
}
else if // other controls type
{
// ...
}
また、 「動的に作成されたコントロールを検証する方法」という質問を参照することもできます。
この質問はその手順に関連していますか?
また、上記の質問で説明したように、検証はクライアント側で行うことができますか?または、作成したフィールドをリストに保存することでサーバー側で、送信時にそのリストを確認できます。