((TextBox)Control)。文本未传递值

时间:2019-08-01 13:23:13

标签: c# html asp.net webforms

EDITH:

我改变了方式,我正在尝试这样做,但仍然没有出错,这是首页:

<asp:Repeater runat="server" ID="rptCamposAnonimo">
     <ItemTemplate>
          <div class='col-md-<%# rptTamanhoA(Container) %>'style='padding-left: 15px; padding-right: 15px;'>
               <label><%# rptNomeA(Container) %>:</label>
               <asp:TextBox runat='server' ID='txtCampoA' CssClass="<%# rptIdA(Container) %>"></asp:TextBox>
           </div>
      </ItemTemplate>
 </asp:Repeater>

工作正常,背部:

try
        {
            foreach (Control ctr in (rptCamposAnonimo.Controls))
            {
                if (ctr is RepeaterItem)
                {
                    foreach (Control rpt in ctr.Controls)
                    {
                        if (rpt is TextBox)
                        {

                            campos.Mensagem = ((TextBox)rpt).Text;
                            campos.Denuncia = denuncia.ID;
                            var idC = rpt as TextBox;
                            campos.ID = Convert.ToInt32((idC).CssClass);
                            Servicos.Campos.SalvarCamposDenuncia(campos);
                        }
                    }
                }
            }
        }
        catch (Exception)
        {
        }

我可以得到所有价值,但((TextBox)rpt).Text却无法获得价值,但是却没有得到价值。

0 个答案:

没有答案