我正在做一个相册,想用dataList批量修改上传相片的信息,在模板里放了两个TextBox,下面有个保存按钮,但我点保存按钮,用(TextBox)dlPhotos.FindControl("txtPhotoName");得不到那个文本框的值啊,请问怎么找能在后台得到DataList控件里控件的值啊!哪位高手帮下,急啊!

解决方案 »

  1.   

    在OnItemCommand事件中用e.Item.FindControl
      

  2.   

    dlPhotos.Items[your row index].FindControl("txtPhotoName")
    PS:看你这结贴率估计也没几个人想回。
      

  3.   

     DataList1.DataSource = ds;
                DataList1.DataBind();            foreach (DataListItem di in DataList1.Items)
                {
                    Label lb = (Label)di.FindControl("Label2");
                    
                  
                }
      

  4.   

    (TextBox)dlPhotos.FindControl("txtPhotoName");
    string value=dlphotos.text;
    value不就是你说的Datalist控件里的TextBox控件的值吗?
      

  5.   

    在按钮事件里 
    foreach (DataListItem item in DataList1.Items)
      {
          TextBox txt= (TextBox)item.FindControl("Txt");
          if(txt!=null)
          {
            
          }
      }
    ItemDataBound里能否查询到textbox,
    TextBox txt= e.Item.FindControl("txt") as TextBox;