Hi,
I'm using Visual Studio 2008 (Asp.net (c#)) and SQl Server 2005
I have a datatable ("dtReportList") generated from database query and then I show the datatable by a gridview.
dtReportList = GetReportList(UserId); //get data from database
GridView1.DataSource = dtReportList;
GridView1.DataBind();
The output data of datatable will be::
ReportId ReportName CreatedDate
1 DummyReport1 21/08/2009
2 DummyReport2 21/08/2009
3 DummyReport4 21/08/2009
I want to modify the DataTable before to assign it to the Grid's DataSource. I want to modify the ReportName data of each row.
I cannot modifed the GetReportList method because is heavily used, so my only chance is to modify the DataTable before I will use it.
Is it possible to do it? How can I do it?
I was thinking to do something like this?
dtReportList = GetReportList(UserId); //get data from database
foreach(DataRow report in dtReportList.Rows)
{
Guid reportId = new Guid(report["ReportId"].ToString());
string reportTitle = GetReportTitle(conn, reportId, UserId,
GetReportLanguage(reportId));
report["ReportName"] = reportTitle;
}
GridView1.DataSource = dtReportList;
GridView1.DataBind();
Thanks again for your help.