Hi,
I have a Datagrid which is getting its data from CSV. No file is sorted in any order, but I want to order the gridview by Username (a field). How could this be done? My XML/gridview code looks like the following:
Streamwriter for writing to csv and populating 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();