Click here to Skip to main content
15,914,419 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Displaying different files in WebBrowser Pin
Bardy855-Aug-08 0:18
Bardy855-Aug-08 0:18 
GeneralRe: Displaying different files in WebBrowser Pin
monica0057-Aug-08 9:37
monica0057-Aug-08 9:37 
QuestionReportViewer print out error Pin
deepthy.p.m4-Aug-08 23:51
deepthy.p.m4-Aug-08 23:51 
QuestionMulti-edit Datagrid with Paging Pin
Member 40748384-Aug-08 23:43
Member 40748384-Aug-08 23:43 
AnswerRe: Multi-edit Datagrid with Paging Pin
Bardy855-Aug-08 0:06
Bardy855-Aug-08 0:06 
QuestionDynamic control add in form and finally store in to database Pin
Member 38798814-Aug-08 23:40
Member 38798814-Aug-08 23:40 
AnswerRe: Dynamic control add in form and finally store in to database Pin
Bardy854-Aug-08 23:56
Bardy854-Aug-08 23:56 
AnswerRe: Dynamic control add in form and finally store in to database Pin
chandralekha5-Aug-08 0:34
chandralekha5-Aug-08 0:34 
For adding textboxes dynamicaly into a form you can either add textbox controls to a form directly or to a placeholder control inside the form.For retriving values correctly i suggest you to place controls inside a placeholder.

You want to create 3 Textboxes in each link button click.Here what i had done is I placed a dropdownlist with items 1,2,3 ..etc.According to the selected item value of the dropdownlist that much set of 3 Textboxes is generated.

For that first I place a DropDownList1,PlaceHolder1 and Button1 in the form.

My code follows


protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < Convert.ToInt16(DropDownList1.SelectedItem.Text); i++)
{
PlaceHolder p2 = new PlaceHolder();
p2.ID = "p2" + i;
PlaceHolder1.Controls.Add(p2);
for (int j = 0; j < 3; j++)
{
TextBox tb = new TextBox();
tb.ID = "TextBoxg"+i + j;
p2.Controls.Add(tb);
RequiredFieldValidator f1 = new RequiredFieldValidator();
f1.ControlToValidate = "TextBoxg" + i+j; ;
f1.ErrorMessage ="*";
p2.Controls.Add(f1);
p2.Controls.Add(InsertBreaks(1));
}
p2.Controls.Add(InsertLineBreaks(2));
}
}
private static Label InsertBreaks(int breaks)
{
Label lblBreak = new Label();
for (int i = 0; i < breaks; i++)
{
lblBreak.Text += " ";
}
return lblBreak;
}
private static Label InsertLineBreaks(int breaks)
{
Label lblLineBreak = new Label();
for (int i = 0; i < breaks; i++)
{
lblLineBreak.Text += "
";
}
return lblLineBreak;
}
protected void Button1_Click(object sender, EventArgs e)
{
string[] data = new string[3];
foreach (Control c in PlaceHolder1.Controls)
{
int yu = 0;
foreach (Control c23 in c.Controls)
{
if (c23.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
data[yu] = ((TextBox)c23).Text;
yu = yu + 1;
}
}
//data[0], data[1], data[2] will contain the datas of each row.
//Here you can give your insert command to the database


}



}
}


Explanation:Here inside PalceHolder1 I dynamically created a placeholder with 3 Text Boxes for each row.According to the selected value of the dropdownlist, number of placeholders are dynamically created inside PlaceHolder1.For each TextBoxes I dynamically created required field validators also.If you dont want validator you can remove it and use.


Hope this code will clear your doubts
Questiontemplatefield Pin
ptvce4-Aug-08 23:25
ptvce4-Aug-08 23:25 
Question[Message Deleted] Pin
deepthy.p.m4-Aug-08 23:12
deepthy.p.m4-Aug-08 23:12 
AnswerRe: want to print Pin
eyeseetee4-Aug-08 23:21
eyeseetee4-Aug-08 23:21 
QuestionAccess page buttons in a custom control Pin
greekius4-Aug-08 22:53
greekius4-Aug-08 22:53 
QuestionHow to get url of last window Pin
anup_dotnet4-Aug-08 22:40
anup_dotnet4-Aug-08 22:40 
AnswerRe: How to get url of last window Pin
NeverHeardOfMe5-Aug-08 0:48
NeverHeardOfMe5-Aug-08 0:48 
GeneralRe: How to get url of last window Pin
anup_dotnet5-Aug-08 19:43
anup_dotnet5-Aug-08 19:43 
QuestionChanging other text box value Pin
sjs4u4-Aug-08 21:40
sjs4u4-Aug-08 21:40 
AnswerRe: Changing other text box value Pin
N a v a n e e t h4-Aug-08 21:52
N a v a n e e t h4-Aug-08 21:52 
AnswerRe: Changing other text box value Pin
Anand Desai4-Aug-08 22:52
Anand Desai4-Aug-08 22:52 
GeneralRe: Changing other text box value Pin
sjs4u4-Aug-08 23:01
sjs4u4-Aug-08 23:01 
GeneralRe: Changing other text box value Pin
Anand Desai4-Aug-08 23:03
Anand Desai4-Aug-08 23:03 
GeneralRe: Changing other text box value Pin
sjs4u4-Aug-08 23:08
sjs4u4-Aug-08 23:08 
GeneralRe: Changing other text box value Pin
Anand Desai4-Aug-08 23:16
Anand Desai4-Aug-08 23:16 
GeneralRe: Changing other text box value Pin
sjs4u4-Aug-08 23:20
sjs4u4-Aug-08 23:20 
QuestionOne session shared by two users [modified] Pin
darthm4-Aug-08 21:32
darthm4-Aug-08 21:32 
AnswerRe: One session shared by two users Pin
N a v a n e e t h4-Aug-08 21:51
N a v a n e e t h4-Aug-08 21:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.