Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1510
How to Export data from Grid into Excel sheet ?
posted

Hi,

Is this the correct way to Export the data ?

It's *working* ... but do I need this session stuff to get the data from the Grid???
If I don't use it ... the _ugTransactions.Rows.Count is just 0

How would you do it ?    This is how I'm doing it now:


UltraWebGridExcelExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.Download;
_transactions = (SortableCollection<AKTransactionTrack>)Session["dataFromGrid"];
_ugTransactions.DataSource = _transactions;
_ugTransactions.DataBind();
//int check = _ugTransactions.Rows.Count;

UltraWebGridExcelExporter1.Export(_ugTransactions);

I've already binded the Datasource to the Grid BEFORE using this code ( so the Grid should have data when I push the "Export" button but stil it's empty ??? ( I'm coming from Windows FORMS, not asp.net ... so I thought of using the session stuff ... probably it's wrong ??? ):

protected void _btnSearch_Click(object sender, EventArgs e)
        {
            string bankanumer = _tbBankanumer.Text.Trim();
            string hofudbok = _tbHofudbok.Text.Trim();
            string reikningsnumer = _tbReikningur.Text.Trim();           

            _transactions = TrackingBusiness.GetAllAKTransactionTracksBySearchCriteria(bankanumer, hofudbok, reikningsnumer);
            Session.Add("dataFromGrid", _transactions);
            _ugTransactions.DataSource = _transactions;
            _ugTransactions.DataBind();
        }