I use linq to sql,i dynamicallu create textobes and radiobuttons as per value of database,
Here is the code for that,
var r = from a in db.EMR_EVENTs
where a.EventID == (int)Session["eventid"]
select new
{
No_Of_Extra_Invitee=a.Allowed_guest_per_invitee
};
var ev1 = r.First();
int? count = ev1.No_Of_Extra_Invitee;
int? rowCount = ev1.No_Of_Extra_Invitee;
Session["rc"] = rowCount;
for (int i = 0; i < rowCount; i++)
{
TextBox txtfirstname = new TextBox();
TextBox txtlastname = new TextBox();
TextBox txtemail = new TextBox();
RadioButton chkmale = new RadioButton();
RadioButton chkfemale = new RadioButton();
txtfirstname.ID = "txtfirstname" + i.ToString();
txtlastname.ID = "txtlastname" + i.ToString();
txtemail.ID = "txtemail" + i.ToString();
txtfirstname.CssClass = "form-control";
txtlastname.CssClass = "form-control";
txtemail.CssClass = "form-control";
txtemail.Text = "E-Mail Address";
txtfirstname.Text = "First Name";
txtlastname.Text = "Last Name";
chkmale.ID = "chkmale" + i.ToString();
chkfemale.ID = "chkfemale" + i.ToString();
chkmale.Text = "Male";
chkfemale.Text = "Female";
pnl.Controls.Add(txtfirstname);
pnl.Controls.Add(txtlastname);
pnl.Controls.Add(txtemail);
pnl.Controls.Add(chkmale);
pnl.Controls.Add(chkfemale);
}
if i got No_Of_Extra_Invitee=2 then i got 6 textbox and 4 radiobuttons
Now i want to saved this control's value(text),though i give it default text,but i want to save it's runtime value so in submit button i implement like this,
protected void Submit(object sender, EventArgs e)
{
int rccount = Convert.ToInt32(Session["rc"]);
ExtraInviteeBL eb = new ExtraInviteeBL();
for (int i = 0; i <rccount; i++)
{
//logic for add value of textbox's and radiobutton's in database
}
but now i don't know how insert value of this textbox and radiobuttns can anyone give me suggestion for that
Thanks in advance..!
mark this answer if it will really help you,
Thanks&Regards
ketan