Dynamic columns in DataGrid, Paging/Sorting and Data Caching

Discussion in 'ASP .Net Datagrid Control' started by Kostia, Apr 16, 2004.

  1. Kostia

    Kostia Guest

    Hi,
    I have a DataGrid that has no columns and that is populated with
    columns based on data obtained from DB during PageLoad in the
    following way:

    //reset adapter and datatable mapping
    oleDbDataAdapter.TableMappings.Clear();
    System.Data.Common.DataTableMapping tableMap =
    oleDbDataAdapter.TableMappings.Add("Table", "SummaryData");
    // create each column in the table
    BoundColumn col = new BoundColumn();
    col.HeaderText=columnsInfo["displayName"].ToString();
    col.DataField=columnsInfo["columnName"].ToString().;
    SumOutTable.Columns.Add(col);
    tableMap.ColumnMappings.Add(new
    System.Data.Common.DataColumnMapping(colstr, colstr));
    oleDbDataAdapter.Fill(dsSummaryData);
    Cache["SummaryResults"]=dsSummaryData;
    SumOutTable.DataSource = dsSummaryData;
    SumOutTable.DataBind();

    onpageindexchanged is called when page is changed and here it is:
    protected virtual void OnPageIndexChanged(Object sender,
    DataGridPageChangedEventArgs
    e)
    {
    // Set CurrentPageIndex to the page the user clicked.
    SumOutTable.CurrentPageIndex = e.NewPageIndex;
    // Rebind the data to refresh the DataGrid control.
    SumOutTable.DataSource = (DataSet)Cache["SummaryResults"];
    SumOutTable.DataBind();
    }

    It seems that Data is there and there are no exceptions however the
    page of the datagrid contains no data and no columns?
    Does it have anything to do with columns being added dynamically?
    How do I solve this problem? Anything that could be said about sorting
    and possible problems I will run into there?
    Kostia
     
    Kostia, Apr 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordo
    Replies:
    0
    Views:
    469
    Jordo
    Oct 31, 2003
  2. avnrao
    Replies:
    3
    Views:
    3,708
    Elad Volpin
    Jun 6, 2004
  3. =?Utf-8?B?amF2YXRvcGlh?=

    Dynamic columns not sorting in DataGrid

    =?Utf-8?B?amF2YXRvcGlh?=, Oct 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    525
    =?Utf-8?B?amF2YXRvcGlh?=
    Oct 2, 2004
  4. Replies:
    5
    Views:
    630
  5. javatopia

    Dynamic columns and sorting/paging in DataGrid

    javatopia, Oct 19, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    139
    javatopia
    Oct 19, 2004
Loading...

Share This Page