Doubt Gets/Sets

Asked

Viewed 90 times

-2

My project has 3 layers, DAL, BLL, Project utilizo ASP.NET

I have an aspx page in the project, which has textbox containing new values for a database update.

In the DAL class I have Entity that automatically created Gets and Sets

My doubt and the following as I pass values to the class.

Because I always passed values via get and set, but here it is already using get.

DALUsuario.Nome = AQUI QUE GOSTARIA DE RECEBER O VALOR DO TEXTBOX

Class to Update.

 public void AtualizarUsuario(int idUsuario)
    {
        TabUsuario DALUsuario = db.TabUsuario.Find(idUsuario);

        DALUsuario.Nome = "";
        DALUsuario.UsuarioId = "";
        DALUsuario.Senha = "";
        DALUsuario.Status = true;
        DALUsuario.DataCriacao = DateTime.Now;
        db.Entry(DALUsuario).State = EntityState.Modified;
        db.SaveChanges();

    }

Page ASPX

protected void btnEdiUsuario_Click(object sender, EventArgs e)
    {
        BLLUsuario = Usuario.DALUsuario;
        BLLUsuario.Nome = txtNomeUsuario.Text;
        BLLUsuario.Email = txtEmailUsuario.Text;            
        ...
        Usuario.AtualizarUsuario(Convert.ToInt32(Request.QueryString["Usuario"]));
    }
  • your question became too vague, I could not understand what you really want. Do you want to use the get/set? update data? retrieve values from textbox? MVC or Webform?

  • @Dorathoto Thanks for the first answer I edited the question for better understanding of all, even of those who have this doubt in the future.

  • Much improved, but I still can not help, put an example of what you are doing, page, etc.

  • 1

    @Dorathoto I ended up solving the problem, edited the question with the answer.

  • correct would be to answer your own question and mark it as the correct one. and not modify the question itself.

  • @Dorathoto Done.! Thank you.

  • 1

    Possible duplicate of Layered communication

Show 2 more comments

2 answers

2

Recover values from Textbox

var Valor = Request.Form["IdTexBox"];

But in Webform I believe it is what you are using (aspx)

<asp:TextBox id="textBoxId" runat="server" ></asp:TextBox>
 var Valor = textBoxId.Text;

In MVC

public ActionResult Index(FormCollection form)
{
var Valor = form["IDTextBox"];

MVC receiving Dalusuario itself as object

public ActionResult Index(DALUsuario user)
{
  • Thank you for the answer more I believe that as the formulation of the question was confused your answer did not resolve =\

0

HICCUP

I passed an object with all the respective data

PÀG ASPX

protected void btnEdiUsuario_Click(Object Sender, Eventargs and) { Bllusuario = User.Dalusuario;

    BLLUsuario.Nome = txtNomeUsuario.Text;
    BLLUsuario.Email = txtEmailUsuario.Text;         
    ...       

Current user(Convert.Toint32(Request.Querystring["User"]), Bllusuario); } CLASS

public void Actualizrusuario(int idUsuario, Tabusuario objDALUsuario) { Tabusuario Dalusuario = db.TabUsuario.Find(idUsuario); ;

    DALUsuario.Nome = objDALUsuario.Nome;
    DALUsuario.DataCriacao = DateTime.Now;
    db.Entry(DALUsuario).State = EntityState.Modified;
    db.SaveChanges();

}

  • mark this answer as accepted has a V green nearby, so everyone will know that this solution solved their problem ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.