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
35
Updating WebGrid gives, The data source 'ObjectDataSource1' only supports a single view named 'DefaultView' error
posted

Hi,

 I'm trying to use the WebGrid to Update and Insert rows in a database using an ObjectDataSource.  I created a very basic page using the information found in Infragistics Help located here. Binding WebGrid to an Object Data Source And I made sure all the checkboxes to create the Update, Insert, and Delete statements were checked.

 I have set the DataKeyField property in both the UltraWebGrid and UltraGirdBand tags to the ID field for the table I'm trying to update.  And I have set all the Allow Updating, Inserting and Adding properties to 'Yes'.

 After doing this I'm able to compile and run the page and it displays the data in the table.  I am able to press the add new row button and the grid displays a new blank row at the bottom of the grid.  Here's where the problems begin.  After entering data into the new row I've tried these methods.

  1. I added a button to the page to cause a PostBack.   The data does not get inserted into the database and I get the following error: ERROR: The data source 'ObjectDataSource1' only supports a single view named 'DefaultView'. You may also leave the view name (also called a data member) empty for the default view to be chosen.
    Parameter name: viewName
  2. I added the OnAddRow="UltraWebGrid1_AddRow" to the <igtbl:UltraWebGrid> tag. And set up the 'UltraWebGrid1_AddRow" method to handle the event (I haven't put any code in the method yet).  Now as soon as I click the button to create my new blank row I get the following error.  I don't even get a chance to enter anything into the cells. ERROR: The data source 'ObjectDataSource1' only supports a single view named 'DefaultView'. You may also leave the view name (also called a data member) empty for the default view to be chosen.
    Parameter name: viewName
  3. I removed OnAddRow="UltraWebGrid1_AddRow" from the <igtbl:UltraWebGrid> tag and instead tired adding the event in Page_Load like this: UltraWebGrid1.AddRow += new Infragistics.WebUI.UltraWebGrid.AddRowEventHandler(UltraWebGrid1_AddRow); This yielded the same error.

If anyone here knows what I need to do to fix this error so I can update and insert with the WebGrid using an ObjectDataSource, I'd be most thankful for a response.  I spent a lot of time looking for a simple example of updating and inserting using WebGrid with an ObjectDataSource but have but have been unable to find any sample code. 

 I'm using

SQL Server 2005, VS 2005 (C#), NetAdvantage for .NET 2008 Vol. 2 and I have installed the NetAdvantage for .NET 2008 Vol. 2 Hot Fix.
Parents
  • 20
    posted

    Hi "ddayagr",

    Our team has run into the same problem.  It appears it is a new issue with 8.2 (we didn't have the problem with 8.1).  Here is how I "fixed" it:

    I created my own class for ObjectDataSource to be used with the grid:

    public class ObjectDataSourceHackedForUltraGrid
      : ObjectDataSource
    {
     
    public ObjectDataSourceHackedForUltraGrid()
        :
    base()
      {
      }

      protected override DataSourceView GetView(string viewName)
      {
       
    return base.GetView("DefaultView");
      }
    }

    I use this instead of the regular ObjectDataSource and it is working so far (but as the name of the class suggests, this is more a like a hack then a real solution.  There really seem to be an issue when using UltraGrid and an ObjectDataSource that returns a DataTable that is part of a DataSet (you don't get this problem when it's not part of a DataSet).

    Hope this helps.

Reply Children
No Data