I have a gridview that for a part of the gridview, I want to do something and for another part, I want to do another thing. Like from the index 0 to index 14, do this. From the index 15 to 30, do that.
My idea is I'm generating a pdf file, and if the GridView has 0-14 rows, it creates 1 page. If it has 15-30 rows, it creates another page with a different design and so on... This happens in a Click event of a "Print" button.
Is it possible and how?
Here's some code I have for this:
string listeMarchandises = String.Empty;
var i = 0;
foreach (GridViewRow row in GridViewMarchandises.Rows)
{
if (i <= 14)
{
if (row.RowType == DataControlRowType.DataRow)
{
Label LabelNumCpte = (Label)row.FindControl("LabelNumCpte");
Label LabelNumCc = (Label)row.FindControl("LabelNumCc");
Label LabelNbrCom = (Label)row.FindControl("LabelNbrCom");
TextBox TextBoxNbrRec = (TextBox)row.FindControl("TextBoxNbrRec");
Label LabelDescription = (Label)row.FindControl("LabelDescription");
TextBox TextBoxCoutUnitaire = (TextBox)row.FindControl("TextBoxCoutUnitaire");
Label LabelCoutTotal = (Label)row.FindControl("LabelCoutTotal");
listeMarchandises += "<tr valign=\"top\"><td align=\"center\">" + LabelNumCpte.Text.Trim() + "</td><td align=\"center\">" + LabelNumCc.Text.Trim() + "</td><td align=\"center\">" + LabelNbrCom.Text.Trim() + "</td><td align=\"center\">" + TextBoxNbrRec.Text.Trim() + "</td><td> " + LabelDescription.Text.Trim() + "</td><td align=\"right\">" + TextBoxCoutUnitaire.Text.Trim() + " $ " + "</td><td align=\"right\">" + LabelCoutTotal.Text.Trim() + " $ " + "</td></tr>";
}
i++;
}
if (i >= 15 && i <= 30)
{
//do the other thing
}
}
Thanks in advance!