Testing this method when in a gridview with checkbox if 1 checkbox is selected, then a modal with that selection is displayed in another gridview, and if 2 or more checkboxes are selected in the first gridview, the selected rows in another gridview are shown. So far so good, but now I need to convert each of the gridview rows in xml to pass it to a webservice, that's the main idea, but the label does not show me more than 1 row, it does not show me 2 or 3 or more rows .
Code:
foreach (GridViewRow row in gwPreview.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
if (chkRow.Checked)
{
string ciudad = (row.Cells[1].FindControl("lblCONSULTA") as Label).Text;
string data = row.Cells[2].Text;
string remision = row.Cells[3].Text;
string fechaEmision = row.Cells[4].Text;
dt.Rows.Add(ciudad, data, remision, fechaEmision);
lblHelper1.Text = "<code>" + " | " + ciudad + " | " + data + " | " + remision + " | " + fechaEmision + "</code>"
}
}
}
gvSelected.DataSource = dt;
gvSelected.DataBind();
Gridview1
ciudad | data | remision | fechaemision | checkbox
----------------------------------------|---------
city1 | 01 | 2448 | 20171010 | X
city2 | 02 | 2447 | 20171021 | X
city3 | 03 | 2457 | 20170928 |
GridviewPreview
ciudad | data | remision | fechaemision |
----------------------------------------|
city1 | 01 | 2448 | 20171010 |
city2 | 02 | 2447 | 20171021 |
lblHelper1 obtained
city1 | 01 | 2448 | 20171010
lblHelper1 Expected result
city1 | 01 | 2448 | 20171010 | city2 | 02 | 2447 | 20171021