从你的代码看,你是在服务器端使用HtmlInputText控件的,那么在html文件中必须加上runat=server;

解决方案 »

  1.   

    to:haohaohaohao() 
    我是在代码里这么动态生成的控件,算不算服务端控件?
    HtmlInputText text1=new HtmlInputText("Text");又如何加:runat=server;
      

  2.   

    你这样加的恐怕不是web控件,还是用textbox吧
    要不然实施看text1.Runat = server;
      

  3.   

    再加上:text1.Attributes.Add("runat","server")
      

  4.   

    我是在代码里这么动态生成的控件,算不算服务端控件?
    HtmlInputText text1=new HtmlInputText("Text");
    text1.Attributes.Add("runat","server");
      

  5.   

    我换成TextBox 控件,为什么还找不到????????????TextBox txt1=new TextBox();
    txt1.ID="Product"+Serial.ToString();
    txt1.BorderStyle=BorderStyle.None;
    txt1.Style["BACKGROUND-COLOR"]="transparent";
    string Product_id=(string)DataBinder.Eval(e.Item.DataItem, "Product_id");
    txt1.Text=Product_id;
    e.Item.Cells[1].Controls.Add(txt1);foreach(DataGridItem item in grid.Items)
    {
    int serial=Convert.ToInt32(item.Cells[7].Text); //得到HtmlInputText 控件的全id;
    string pro_id="grid__ctl"+(serial+1).ToString()+"_Product"+serial.ToString();
    TextBox txt1=(TextBox)item.Cells[1].FindControl(pro_id);
    //用HtmlInputText控件的id;
    string pro_id2="Product"+serial.ToString();
    TextBox txt12=(TextBox)item.Cells[1].FindControl(pro_id);

    }txt1,txt12还是为空,怪??
    到底在DataGrid的单元格里查找控件的关键在哪里呢??
      

  6.   

    我换了种方式,先把控件添加进去,而不是动态的Add(txt1);
    可以找到了,但不知为什么?