J'ai une Datagrid qui obtient ses données de CSV. Aucun fichier n'est trié dans un ordre quelconque, mais je veux commander le gridview par nom d'utilisateur (un champ). Comment cela pourrait-il être fait? Mon XML/code gridview se présente comme suit:Peut-on trier un gridview lié à un objet personnalisé (fichier CSV)?
streamWriter pour écrire à csv et peuplant gridview:
string filename = @"D:\www\isolated\LocalUser\cc-suppressions\generatedsuppressions\surpressions.csv";
StreamWriter sWriter = new StreamWriter(Server.MapPath("Surpression.csv"));
string Str = string.Empty;
string headertext = "";
sWriter.WriteLine(headertext);
int cellLimit = GridView3.Rows[1].Cells.Count;
for (int i = 0; i <= (this.GridView3.Rows.Count - 1); i++)
{
for (int j = 0; j <= (this.GridView3.Rows[i].Cells.Count - 1); j++)
{
Str = this.GridView3.Rows[i].Cells[j].Text.ToString();
if (Str == " ")
Str = "";
Str = (Str + ",");
sWriter.Write(Str);
}
sWriter.WriteLine();
}
sWriter.Close();
sWriter.Dispose();
}
this.GridView3.DataBind();