1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| DataTable GetTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("Label");
dt.Columns.Add("CategoryId");
dt.Columns.Add("ProgramId");
dt.Columns.Add("Title");
dt.Columns.Add("ShopName");
dt.PrimaryKey = null;
foreach (GridViewRow ligne in GridViewShops2.Rows)
{
DataRow dr = dt.NewRow();
if (ligne.Cells[4].Text != null)
{
string hs = this.Server.HtmlDecode(ligne.Cells[4].Text);
dr["ShopName"] = hs;
}
if (ligne.Cells[3].Text != null)
{
string hs = this.Server.HtmlDecode(ligne.Cells[3].Text);
dr["Title"] = hs;
}
if (ligne.Cells[2].Text != null)
{
string hs = this.Server.HtmlDecode(ligne.Cells[2].Text);
dr["ProgramId"] = hs;
}
dr["CategoryId"] = ligne.Cells[1].Text; // tu peux faire comme ça pour chaque ligne, j'ai utilisé les if car j'avais des accents et ça ne marchait pas
if (ligne.Cells[0].Text != null)
{
string hs = this.Server.HtmlDecode(ligne.Cells[0].Text);
dr["Label"] = hs;
}
dt.PrimaryKey = null;
dt.Rows.Add(dr);
} |
Partager