Hi florenz,
I have created one sample please refer the below code.
HTML
<asp:Panel runat="server" ID="pnl">
</asp:Panel>
<div>
<asp:Button Text="Generate" runat="server" ID="btnGenerate" OnClick="GenerateClick" />
</div>
Code
protected void GenerateClick(object sender, EventArgs e)
{
List<Patient> patientList = new List<Patient>();
patientList.Add(new Patient() { PatientId = 1, PatientName = "Patient1" });
patientList.Add(new Patient() { PatientId = 2, PatientName = "Patient2" });
patientList.Add(new Patient() { PatientId = 3, PatientName = "Patient3" });
patientList.Add(new Patient() { PatientId = 4, PatientName = "Patient4" });
patientList.Add(new Patient() { PatientId = 5, PatientName = "Patient5" });
for (int i = 0; i < patientList.Count; i++)
{
TextBox txt = new TextBox();
txt.ID = "txtPatient" + (i + 1);
txt.Text = patientList[i].PatientName;
pnl.Controls.Add(txt);
pnl.Controls.Add(new LiteralControl("<br />"));
}
}
public class Patient
{
public int PatientId { get; set; }
public string PatientName { get; set; }
}
Screenshot
