DataBind GridView to a DataViewManager in ASP.NET

Discussion in 'ASP .Net' started by ack95, Dec 14, 2006.

  1. ack95

    ack95 Guest

    Simply question
    How can I DataBind() a DataViewManager to a GridView in ASP.NET?

    Question in Detail
    We have a DataSet with relational DataTables (total of 5). We are
    generating emails with user specific data, so instead of going back to
    the DB for every user, we are getting all data once and filtering on
    the DataSet per user (most data overlaps users so this seems like a
    good strategy). Our main GridView has child GridView controls that our
    bound via CreateChildView(). All is well except for the fact that I
    cannot filter on a related DataTable (B) in the DataSet and then
    DataBind to related DataTable (A) and the results be filtered due to
    the relationship. My only options are 1) using the Select() method on
    the DataTable (A) which will not work b/c I cannot bind DataRow[] to a
    GridView and 2) setting the RowFilter on DataTable (B)'s DefaultView
    then binding DataTable (A)'s DefaultView as this will result in
    unfiltered results, making it pointless. So, I have been looking into
    the DataViewManager and as I understand it, it is very much like the
    DataSet, but for the DataViews instead of DataTables. This is great
    because I can simply set the RowFilter on a DataView inside the
    DataViewManager (i.e.
    ds.DefaultViewManager.DataViewSettings["DataTableName"].RowFilter = "ID
    = 100";) and then bind the DataViewManager to the GridView! Oh, if it
    were only that easy. I cannot find any good example of how to do this
    nor can I get it to work on my own.

    This is how it is done in Windows forms:

    dataGrid.SetDataBinding(dvm, "DataTableName");



    I've tried this in ASP.NET and it was unsuccessful as I receive an
    error stating:
    "The data source for GridView with id '' did not have any properties or
    attributes from which to generate columns. Ensure that your data
    source has content.":

    gv.DataSource = ds.DefaultViewManager;
    gv.DataMember = "DataTableName";
    gv.DataBind();


    Any help would be greatly appreciated!
     
    ack95, Dec 14, 2006
    #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. martin
    Replies:
    0
    Views:
    379
    martin
    Apr 21, 2004
  2. Using DataViewManager with a WebControls.DataGrid

    , Jun 16, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    163
    Teemu Keiski
    Jun 20, 2005
  3. Michael
    Replies:
    0
    Views:
    231
    Michael
    Dec 29, 2003
  4. Using DataViewManager with a WebControls.DataGrid

    , Jun 15, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    114
  5. Jiho Han

    Binding DataGrid with DataViewManager

    Jiho Han, Feb 18, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    142
    Jiho Han
    Feb 18, 2004
Loading...

Share This Page