473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

misformed QueryString Error / ObjectDataSource

Paxxer
22
Hi All,

I'm using an URL?ID=F28C680E-BC0B-485D-8CFE-8BC29656BF71 as a method parameter for an objDataSource.

That is a GUID from the query string.

So in testing I wanted to see what would happen if a person browsed to the page without an ID field in the QueryString,

And of course a error is thrown, "Can't covert 0000000-0000-0000-0000-000000 to a GUID"

Which is expected.

My Question is this: Where would I check that the ID isn't a proper GUID, prior to the ObjDataSource getting all upset?

thanks
Feb 5 '09 #1
7 2323
Frinavale
9,735 Expert Mod 8TB
Validate the parameter before you access the ObjDataSource....
First check the parameter where ever you are accessing the ObjDataSource.

It's as simple as adding an If (MyParameterIsValid) statement before accessing the ObjDataSource.
Feb 6 '09 #2
Paxxer
22
Thanks Frinavale,

Let me add some more details.

There is no "code" in the code behind page. I have the ObjectDataSource acting as the dataobject for an asp:GridView. All of the "Accessing" is taking place behind the seens.

So my question is actually:

Which event is the correct place to check for the validity of the QueryString ID so I can cancel the ObjectDataSource, trying to use it as a parameter?

Thanks
Feb 6 '09 #3
Frinavale
9,735 Expert Mod 8TB
Naturally you do not want to attempt to show content for something that doesn't exist.

In this case, I would recommend that you do your validation in the Class that you have developed to server as your data source .

In the case that the validation should fail throw a *custom exception.
You can then catch this exception in yourPage Error Event in order to display something user friendly.

For an example of how implement your data source Class in such a way that it throws an error see the ObjectDataSource Class.

I found this interesting while researching your problem.


*Please note that the article linked to has you inherit from BaseException, it should just be Exception because Exception is the base class for all Exceptions.
Feb 6 '09 #4
Paxxer
22
Thanks for the efforts,

Sure, I can "Make it work", with a hack here or there.

But it seems that I should be able to cancel the selecting request on the ObjectDataSource before it raises an error.

I couldn't find the event to do this in.
Feb 6 '09 #5
Frinavale
9,735 Expert Mod 8TB
Have you considered dynamically creating the ObjectDataSource?
You would have a lot more control over it in code.

Check out this article. It has a lot of information there on the ObjectDataSource.
Feb 6 '09 #6
Paxxer
22
I've moved on, with a workaround.

I'm curious about which is the correct Event, not other workarounds.

Thanks
Feb 6 '09 #7
Frinavale
9,735 Expert Mod 8TB
The article that I linked you to suggests that you implement your validation rules in your Business Logic Layer (in your Class). However, the example they give doesn't include how to do this ("for simplicity sake").

I've been reading up on this all day (thanks :)) and I'm almost certain that there is no event for this process.

You'll either have to dynamically create the ObjectDataSource for the GridView at run time in order to handle validation before it's accessed, or you have to implement validation in your Class.

-Frinny
Feb 6 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dotnet Gruven | last post by:
I've posted this in the adonet group, however it was suggested I might have better luck here.... ============================================================= I'm trying to use a typed dataset and...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
1
by: tparks69 | last post by:
I get the error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Insert' that has parameters: last_name, first_name, email, role_id, user_id, modified_by, modified_date...
6
by: miky | last post by:
Hi, I'm trying to get custom gridview paging working and I'm getting the following error: "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'count' that has parameters:...
3
by: siamesedream | last post by:
Hello, I'm having trouble using the insert method of an ObjectDataSource that uses a custom DataObjectType. If I'm using a custom DataObjectType does my insert method have to take that object,...
0
by: =?Utf-8?B?RGVuaXMgU29oZXQ=?= | last post by:
Hi all, I've created a new project to test ObjectDataSource component. I've just added a new objectdatasource, configured it (linked to a table) etc ... It works fine on localhost, i can...
0
by: mrajanikrishna | last post by:
Hi friends, I have placed a GridView and its DataSourceId is ObjectDaatSource1. <asp:ObjectDataSource id="ObjectDataSource1" runat=server TypeName="AuthorsDb" SelectMethod="GetStates"/> My...
1
by: Allan Ebdrup | last post by:
I have a asp.net v2 website that runs fine on our development server. I have published the website to a stage server and it runs fine, but when I publish it to production I get the following error:...
0
by: Cirene | last post by:
Using Visual Studio I created a DataSet using the GUI (XSD file). Trying to use a tiered methodology I called the functions from my BLL. Namespace Zzz.BusinessLogicLayer #Region "DAL Access"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.