请帮助解决这个问题 [英] Kindly help for this problem
问题描述
您好b $ b我有一个下拉列表ddlProduct名称和数量文本框。当我选择产品名称并在我的文本框中写入数量并单击Button1时,根据数量值在我的占位符中生成多个文本框。但当我再次选择另一个产品和数量并单击按钮1时,当前数量文本框正在生成,而不显示以前选择的文本框。我需要生成现有产品和之前产品的textboes。两者都应该出现在我的占位符中。我该怎么做呢。请帮助。
受保护 void Button1_Click( object sender,EventArgs e)
{
{
if (txtQuantity.Text!= )
{
for ( int i = 0 ; i < Convert.ToInt16(txtQuantity.Text); i ++)
{
标签la = 新标签();
la.Text = ddlProductName.SelectedItem.Value + i.ToString();
la.ID = abc + i.ToString();
PlaceHolder1.Controls.Add(la);
// la = FindControl(String.Format(i))as Label;
TextBox txtbox = new TextBox();
txtbox.Text = Textbox - + i.ToString();
PlaceHolder1.Controls.Add( new LiteralControl( < input id ='txt'name ='Textbox + i + 'type ='text'/>));
PlaceHolder1.Controls.Add( new LiteralControl(
));
}
}
}
}
< blockquote>
希望你错过将文本框控件添加到PlaceHolder
TextBox txtbox = new TextBox();
txtbox.Text =Textbox - + i.ToString();
PlaceHolder1.Controls.Add(txtbox);
并查看更多帮助
< a href =http://msdn.microsoft.com/en-us/library/kyt0fzt1(v=vs.110).aspx> http://msdn.microsoft.com/en-us/library/kyt0fzt1( v = vs.110).aspx [ ^ ]
Hi
I have a dropdownlist ddlProduct Name and quantity text box. When I Select a Product Name and write the quantity in my textboxes and click the Button1 that number of textboxes are generating in my place holder according to quantity value. but when I am again go to choose the another product and quantity and click the Button 1 then the current quantity textboxes are generating and not showing the previous selected textboxes. I need to generate the textboes of present product and previous. Both should appear in my place holder.How will i Do it. Kindly Help.
protected void Button1_Click(object sender, EventArgs e)
{
{
if (txtQuantity.Text != "")
{
for (int i = 0; i < Convert.ToInt16(txtQuantity.Text); i++)
{
Label la = new Label();
la.Text = ddlProductName.SelectedItem.Value + i.ToString();
la.ID = "abc" + i.ToString();
PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox = new TextBox();
txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder1.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='text' />"));
PlaceHolder1.Controls.Add(new LiteralControl("
"));
}
}
}
}
hope so you are missing to add the textbox control to PlaceHolder TextBox txtbox = new TextBox(); txtbox.Text = "Textbox - " + i.ToString(); PlaceHolder1.Controls.Add(txtbox);
And see for more help
http://msdn.microsoft.com/en-us/library/kyt0fzt1(v=vs.110).aspx[^]
这篇关于请帮助解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!