GridView ( and tableadapter queries RRS feed

  • Question

  • I am using a gridview in  In windows forms I can bind a gridview to a query in a tableadapter by using the table adapters fill method.  In one of the queries I have a computed column using two fields.  in the windows forms environment, I can see this computed column when binding the gridview to the tableadapter.  in however, when I bind the gridview using an objectdatasource, I can select the table adapter's GetBy method, but for some reason the computed column does not appear.  it's like it is pulling the fields defined in the datatable but not what I have in the tableadapters query.  anyone know why this is, and is there a good place to learn about binding gridviews using datatables for



    Also, when loading a form in windows forms environment, I can change the data in a gridview by using the fill method.  That way I can change the contents of the gridview on the fly based on the queries in the tableadapter.  is there similar functionality in  I haven't had success replicating this behavior in






    by the way, I tried the same method on a datagrid and it worked.  the gridview dosen't appear at all when I run it.  here is the code to populate the gridview:


    Code Snippet

    ApplicationData d = new ApplicationData();

    DataView dv = d.capitalItemDollars(true, "63", 0);

    this.GridView1.DataSource = dv;



    Here is the method I created to populate the dv:


    Code Snippet

    public DataView capitalItemDollars(bool active, string departmentID, int capitalItemID)




    CapitalRequestDataSet capitalRequestDataSet = new CapitalRequestDataSet();

    CapitalRequestDataSetTableAdapters.cv_capital_item_dollars_usedTableAdapter cv_capital_item_dollars_usedTableAdapter;

    cv_capital_item_dollars_usedTableAdapter = new CapitalRequestDataSetTableAdapters.cv_capital_item_dollars_usedTableAdapter();

    cv_capital_item_dollars_usedTableAdapter.FillByDepartmentID(capitalRequestDataSet.cv_capital_item_dollars_used, active, departmentID, capitalItemID);

    DataView dv = new DataView(capitalRequestDataSet.cv_capital_item_dollars_used);

    return dv;


    catch (SqlException ex)


    return null;


    catch (Exception ex)


    return null;





    Now, if I put a standard datagrid on the web page and change the first code block to populate the datagrid, it works.  but when I try to populate the gridview, as I said, nothing appearson the web page.
    Tuesday, September 18, 2007 8:20 PM


  • ok, when I changed the method that populates the dataview to one that populates a dataset, and set the datamember method of the gridview, it worked.

    Tuesday, September 18, 2007 9:49 PM
  • That is correct what you did was for Winform and not Webform so spend time with the work around solutions most people are not happy with it.


    Tuesday, September 18, 2007 9:58 PM

All replies