ASP.NET Web Controls >> Problem woth ObjectDataSource and Dataset...

by Paolo » Sat, 09 Sep 2006 21:55:12 GMT

Hi all!

I have a problem, that seems rather common, but I didn't find any
soution.
I have a gridView bound to an ObjectDataSource. The selectMethod
returns a dataSet with multiple DataTable, but I can't choose which
datattable to use, it always uses the first one.- If I use the
DataMember property I get an exception saying that I can use only the
default view, which means I can't set the dataMember property.Is there
a solution? Otherwise I should use a DataSet for each table, but it
semms to me this is a big bug in the framework!

Thank you

Paolo


Similar Threads

1. Problem woth Designer & Serialization - CSharp/C#

2. DetailsView ObjectDataSource and strongly typed dataset

When I found out about the detailsview control, I thought it would save me a 
lot of time when doing basic table updates.

All my business logic layer uses strongly-typed datasets, and I did plug a 
detailsview using an objectdatasource, seems to work fine, until the 
database returned a DBNull.

The error I got is:

Property accessor 'WebsiteUrl' on object 'ArtistDataSet+ArtistRow' threw the 
following exception:'The value for column 'WebsiteUrl' in table 'Artist' is 
DBNull.'

Of course what is the error is a cast error between System.String and DBNull

But seriously? Aren't there any way at all to avoid this error? Otherwise I 
can't use detailsview or formview at all.

Thank you. 


3. ObjectDataSource field binding to DataSet does not work - ADO.Net

4. DetailsView ObjectDataSource, and DataSet: Confused

I am new to asp.net and am learning the concepts and terminology as I
go, so please excuse me if I'm really off base here...

I am trying to add a DetailsView control to a page and have read up on
it and it sure looks easy in all the tutorials I read.  However, I do
not wish to use textual SQL statements for my selects/updates/deletes
as the tutorials I have read describe.  I already have a DataSet in my
project that has definitions for all my tables and would like to use
that as the datasource for my DetailsView control.

So here's what steps I take.  In Design Mode in VS.NET2003, I select
the data source for the DetailsView control.  I select "New Data
Source" and then choose and "Object" data source.  I select the
DataSet1TableAdapters.userTableAdapter (I'm creating a user edit page
for admins to edit user information) and continue.

Now is where I start having problems.  Now under the Update and Delete
tabs there are no methods for me to select.  I did some research and
found that I can create methods for updating and deleting data in the
DataSet by visiting the DataSet's TableAdapters properties and so I
did that; I created a stored procedure that I can use to update data,
and then I selected that stored procedure as the UpdateCommand in the
properties of the DataSet's TableAdapters.   Then I was given that
UpdateUser(Int32 id, String username, String password, [...]) as an
option under the Update tab of that Configure Data Source window.

I will be using a DataGrid for the admin to select the user to edit
and then the DetailsView will only show that user's info, so I have
set the DefaultMode of the DetailsView to Edit.  Now when I run the
site I actually see data in the DetailsView but when I edit it and
press "Update", there is a postback and the original data reappears.
I tried debugging by assigning a method to run on ItemUpdating that
would loop through the new values.  Well I did just that:

void DetailsView1_ItemUpdating(object sender,
DetailsViewUpdateEventArgs e)
    {
        string value;
        for (int i = 0; i < e.NewValues.Count ; i++)
        {
            value = e.NewValues[i].ToString();
        }
    }

and put a breakpoint at the entrance but when I clicked Update on the
web form and I stepped through the code, that "value" variable I have
always contained the _old_ values, not the newly entered ones.

So this is sort of an all around question because I don't know if I'm
doing this all wrong or if I'm just missing something.  I'm leaning
towards the former because another issue I can't seem to answer is how
to pull up a specific record via the DetailsView (currently it always
just pulls up the first row of the table, but obviously I will want to
pull up a specific row to edit).

I've been searching google and trying all kinds of things for hours
and hours.  If someone could point me in the right direction I'd
really appreciate it!

Thanks,
Noah

5. Dataset from ObjectDataSource always null? - ASP.NET Web Controls

6. ObjectDataSource & Typed Dataset Can not update.

I have an ObjectDataSource that uses a typedDataSetAdapter for it data 
source.  The DataAdapter has been configured to use a storeprocedure for 
select another sproc for Insert and another sproc for Update.  I used the 
ObjectDataSource as the data source for a grid view.  I have not been able to 
Update I get an error:

ObjectDataSource 'odsJ' could not find a non-generic method 'Update' that 
has parameters: ContractID, JournalDT, JournalEntry, Private, UserID, 
original_JournalID. 

Please help

7. ObjectDataSource to DataTable or DataSet - Asp.Net

8. ObjectDataSource, Opportunistic Concurrency, Typed Dataset and timestamp field question

Hi

I'd like to use the timestamp and primary key fields to check Opportunistic 
Concurrency violations rather than having to compare all values as is the 
suggested method when using the ObjectDataSource.

The timestamp field is read-only  in the DataTable (this seems logical). 
This means I can't save the original value before an Update which I need to 
get from the ObjectDataSource.

Does anyone have a suggestion?

Many thanks

Andrew