Error deleting row in GridView ASP.NET C # [duplicate]

1

I have the following GridView :

IfIdeletealinefromGridandtrytosaveit,itreturnsthefollowingerror

  

Theinputstringwasnotinacorrectformat.

Thiserrorgivesassoonasitentersthemethod,inthefirstiteminthelist

objBonusValor.BonFxCodigo=Convert.ToInt32(faixaGrid.Split('$')[0]);

ButwhenIaddalineandsaveitright.

Followcodes.

Saveevent:

protectedvoidbtnSalvar_Click(objectsender,EventArgse){try{List<BonusValor>listaBonus=MontarListaBonusValor();if(listaBonus.Count>0){using(TransactionScopetrans=newTransactionScope(TransactionScopeOption.Required,PCIGlobal.SetarOpcoesTransacao())){BonusValorobjBonusValor=newBonusValor();objBonusValor.DeletarBonusValor();foreach(varfaixainlistaBonus){faixa.InserirFaixaValor();}trans.Complete();trans.Dispose();}mensagens.ExibirMensagem("Mensagem", mensagens.strMsgIncluido, true, this.Page, this.GetType());
        }
    }
    catch (Exception ex)
    {

        metodos.AnalizarErro(ex.Message, Request.CurrentExecutionFilePath, this.Page, this.GetType());
        mensagens.ExibirMensagem("Erro", mensagens.strMsgErroGenerico, false, this.Page, this.GetType());
    }
}

MontarListaBonus () method :

 protected List<BonusValor> MontarListaBonusValor()
{
    try
    {
        List<BonusValor> lista = new List<BonusValor>();
        for (int i = 0; i < hdfTable.Value.Split('|').Length; i++)
        {
            if (hdfTable.Value.Split('|')[i].Trim().Length > 0)
            {
                BonusValor objBonusValor = new BonusValor();
                string faixaGrid = hdfTable.Value.Split('|')[i].Trim();
                if (!string.IsNullOrEmpty(faixaGrid))
                {
                    objBonusValor.BonFxCodigo = Convert.ToInt32(faixaGrid.Split('$')[0]);
                    objBonusValor.BonFxVlrInicial = Convert.ToDecimal(faixaGrid.Split('$')[1]);
                    objBonusValor.BonFxVlrFinal = Convert.ToDecimal(faixaGrid.Split('$')[2]);
                    objBonusValor.BonFxVlrBonus = Convert.ToDecimal(faixaGrid.Split('$')[3]);
                    objBonusValor.BonFxIdInc = Session["login"].ToString();
                    objBonusValor.BonFxDtInc = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                }
                lista.Add(objBonusValor);
            }

        }
        return lista;
    }
    catch (Exception ex)
    {

        throw ex;
    }
}
    
asked by anonymous 26.06.2017 / 18:47

0 answers