TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepak Pandey
NA
75
0
Create Dynamic Textboxex and Get values
Sep 22 2011 12:42 AM
Hello,
I want to create more then one text box at run time and also the data of Textbox created on the run time.
as i forgotten mention that I am creating these dynamic textbox for the SelectedIndexChange event of dropdown
Below is code that i am using
protected void ddlAnswerChoices_SelectedIndexChanged(object sender, EventArgs e)
{
Int32 choice=Convert.ToInt32(ddlAnswerChoices.SelectedItem.Value);
for (int i = 1; i <= choice; i++)
{
LiteralControl literal = new LiteralControl();
literal.Text = "<br /><br />";
Label newLabel = new Label();
newLabel.Text = "Choice" + " " + i.ToString();
newLabel.ID = "lblChoice" + i.ToString();
newLabel.Attributes.Add("runat","Server");
this.panelLabel.Controls.Add(newLabel);
this.panelLabel.Controls.Add(literal);
}
for (int j = 1; j <= choice; j++)
{
LiteralControl literal = new LiteralControl();
literal.Text = "<br /><br />";
TextBox nexText = new TextBox();
nexText.ID = "txtChoice" + j.ToString();
nexText.Attributes.Add("runat", "Server");
panelTextbox.Controls.Add(nexText);
this.panelTextbox.Controls.Add(literal);
}
}
I am using above code to create the Textbox dynamically.
Now i facing trouble how to retrieve the data of the these Textbox after the clicking on the submit button so that i can store the values of there Textboxes to database.
what will be code written for the click event of btnSave
protected void btnSave_Click(object sender, EventArgs e)
{
}
Thank in advance
Deepak Pandey
Reply
Answers (
2
)
How to make single form for user and admin
Calling exe via windows service in C#.net(windows 7)