如何在我的占位符中生成当前和以前的Textboes [英] How both present and previous Textboes will be generated in my place holder

查看:74
本文介绍了如何在我的占位符中生成当前和以前的Textboes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个下拉列表ddlProduct名称和数量文本框。当我选择产品名称并在我的文本框中写入数量并单击Button1时,根据数量值在我的占位符中生成多个文本框。但当我再次选择另一个产品和数量并单击按钮1时,当前数量文本框正在生成,而不显示以前选择的文本框。我需要生成现有产品和之前产品的textboes。两者都应该出现在我的占位符中。我该怎么做呢。请帮助。







 受保护  void  Button1_Click( object  sender,EventArgs e)
{

{
if (txtQuantity.Text!= < span class =code-string>)
{
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( < br />));

}
}
}

}

解决方案

< blockquote> on post动态控件将丢失。



点击链接



如何在ASP.NET中动态创建控件并从中检索值 [ ^ ]



http:/ /www.aspsnippets.com/Articles/Dynamic-Controls-Made-Easy-in-ASP.Net.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("<br />"));

                    }
                }
            }
        
    }

解决方案

on post dynamic controls will lost.

follow the link

How to create controls dynamically in ASP.NET and retrieve values from it[^]

http://www.aspsnippets.com/Articles/Dynamic-Controls-Made-Easy-in-ASP.Net.aspx[^]


这篇关于如何在我的占位符中生成当前和以前的Textboes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆