Hi,
The result set from database comes back as the following data. It is parent child relation. TransactionID 1009 has 3 child records in the database with 3 accounts. The total transaction amount is $12/- (3 + 4+5).
So parent table has ID and other data. Child table has Account#, AccountName, Amount, parentID and some other fields.
ID Name Account# AccountName Amount
1007 Sam 31747 a 1
1008 Sam 31748 av 2
1009 Sam 31797 ab 3
1009 Sam 31798 ac 4
1009 Sam 31799 ad 5
When it is displayed in the radgrid, we are showing it like this:
ID Name AccountNum AccountName Amount
1007 Sam 31747 a 1
1008 Sam 31748 av 2
1009 Sam 31797 Ab ($3) 12
31798 Ac ($4)
31799 Ad ($5)
We are achieving this by doing this logic:
While (reader.Read())
{
//logic to check old transaction or new transaction by comparing ID
If (newID != oldID)
{
//new transaction. So do the code
}
Else
{
//still previous transaction. So concatenate account numbers
accountNum += "<
br
/>" + reader.GetString(reader.GetOrdinal("AccountNumber"));
accountName += "<
br
/>" + reader.GetString(reader.GetOrdinal("AccountName"));
amount += reader.GetDecimal(reader.GetOrdinal("Amount"));
}
}
I want this grid data to be exported to BIFF format excel like this:
ID Name Account# AccountName Amount
1007 Sam 1
31747 a
1008 Sam 2
31748 av
1009 Sam 12
31797 Ab ($3)
31798 Ac ($4)
31799 Ad ($5)
I tried using ExportInfrastructure and shiftingRowsDown method in a loop, it works for only 1007 and 1008 rows. But not to 1009. I understand why. That has been treated as 1 row eventhough there are multiple accounts. The account# column is just string concatenation. So, when I am exporting looks like I need to use my original dataset.
I tried to create another radgrid programmatically and assign original result set. We have a btn upon clicking it, I export data to excel like this:
protected void btnExport_Click(object sender, EventArgs e)
{
radGrid.Page.Response.ClearHeaders();
radGrid.Page.Response.Cache.SetCacheability(HttpCacheability.Private);
radGrid.MasterTableView.ExportToExcel();
}
protected void rgdChecks_BiffExporting(object sender, Telerik.Web.UI.GridBiffExportingEventArgs e)
{
}
Where should I programmatically create radgrid and do customize data to look like above.
We do not want to use hierarchical grid.
Please let me know how to get this kind of output?
Thanks,
Prathiba.