CodeBehind for ObjectDataSource.TypeName

M

mofsoft

Visual Studio 2005/ ASP.Net 2.0
DAL in C# exclusively using XSD (strongly typed datasets)
WEB in C# references the DAL as needed via ObjectDataSources

My app has about 5 or 6 "reference" tables that I am creating a
"maintenance" web page for. The page has a dropdown control that lists
all of the reference table names. You pick the "Status Ref" item and
the GridView is refreshed to show the status data. Pick the "Stage
ref" item and the GridView is refreshed it show the stage data...you
get the idea.

The SelectedIndexChanged event on the dropdown table does something
similar to the following:

string ta = ddl.SelectedValue;
string typName = "DAL.dalTableAdapters." + ta + "TableAdapter";
ods.TypeName = typName;
gv.DataSourceID = ods.ID;

The ods is an object in the HTML markup where GetData, Update, etc are
all set...just TypeName is empty.

When the GridView refreshes to show the data, all looks well. However,
clicking Edit on the GridView produces the following error:

A type must be specified in the TypeName property of ObjectDataSource
'ods'.

I can overcome this by assigning the TypeName in Page_Load...but then I
lose all of the updated values. Looking at the sql trace stuff it's
the old values that are being posted back which tells me that if I set
TypeName in Page_Load I am overwriting the values.

So, you can see the dynamic need to have the TypeName blank in the html
markup and have it set dynamically on SelectedIndexChanged. The only
other solution is to create a separate page for each reference table
with all of the proper tableadapater stuff hard coded in the html
markup...I'd prefer not to do that.

Any ideas?
 
Joined
Aug 26, 2006
Messages
1
Reaction score
0
Any Luck Yet?

I've the same issue, only with 15-20 Reference Tables. I really do not want to create a new page or new ObjectDataSource for each set of LookUp data I need to populate the Reference Tables.

Have you made any progress? Any advice?

Alex
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top