1
I’m trying to include several lines in a Gridview, but it doesn’t add the lines, it always replaces the first.
I would like to know how to make it add several lines, and not replacing the first.
Follow the code of how I’m currently doing:
dt.Columns.Add("ID");
dt.Columns.Add("Nome");
dt.Columns.Add("Quantidade");
dt.Columns.Add("Valor");
dt.Columns.Add("Desconto");
dt.Columns.Add("Valor Final");
dt.Columns.Add("Quitar", typeof(bool));
DataRow dataRow = dt.NewRow();
dataRow[0] = txtidprodutoAdd.Text;
dataRow[1] = cbProdutoAdd.SelectedItem;
dataRow[2] = UpQuantidade.Text;
dataRow[3] = txtValorAdd.Text;
dataRow[4] = txtDescontoAdd.Text;
dataRow[5] = txtValorFinalAdd.Text;
dataRow[6] = true;
dt.Rows.Add(dataRow);
GridView5.DataSource = dt;
GridView5.DataBind();
Okay, on the question: where are you trying to insert a second line? In the code only one line is being created.
– Jéf Bueno
It is the same code, I have a button that opens a modal, through filling the data, is included in gridView. And it’s replacing the line, I use this code, it’s on the button.
– Mariana
I’m writing an answer.
– Jéf Bueno