Getting value inserted in Asp text field. Net

Asked

Viewed 29 times

1

I have a GridView and in one of the columns I have a field textbox where I insert values into them.

I would like to know how to get the typed values of the fields, I have already done the following:

for (int i = 0; i <= gvTeste.Rows.Count - 1; i++)
{
    string variavel = gvTeste.Rows[i].Cells[8].Text
}

But it is always returning me empty, as if nothing was filled in cell 8 which is where I entered the value.

  • Voce can put more of the code? in my test works with .Value.Tostring() but has to see how you are building this grid...

1 answer

1


I believe you will need to use a Databound event to retrieve the values, similar to this.

protected void gvTeste_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
      var variavel = (TextBox)e.Item.FindControl("seu campo txt");
}

With this you will get all values of the field reported in Findcontrol.

  • it worked, I did so Textbox txtQtde = (Textbox)gvTeste.Rows[i]. Cells[8]. Findcontrol("txtTeste"); I did not need to put in a Databound

  • Nice Arthur, nice to know that this way too.

Browser other questions tagged

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