能动态添加就是不怎会定位....
        for (j = 0; j < ds.Tables[0].Rows.Count; j++)//ds为Dataset的对象,
        {
            
string strname1 = ds.Tables[0].Rows[j][0].ToString();

            HtmlGenericControl div 
= new HtmlGenericControl("div");
            div.Style.Add(
"width""100px");
            div.Style.Add(
"height""40px");

            Label lab 
= new Label();
            TextBox txt 
= new TextBox();
            txt.ID 
= "txt_object" + j.ToString();
            lab.Text 
= strname1 + "";
            txt.Width 
= Unit.Pixel(50);
            div.Controls.Add(lab);
            div.Controls.Add(txt);

            
this.Page.Form.Controls.Add(div);
        }
得到文本框里面得值
    protected void Button1_Click(object sender, EventArgs e)
    
{
           
int i = 1;//假定i为1

           objText 
= ((TextBox)form1.FindControl("txt_object" + i.ToString())).Text.ToString();
           Response.Write(objText);
    }
posted on 2007-04-18 15:19  下风  阅读(1972)  评论(3编辑  收藏  举报