473,405 Members | 2,282 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,405 software developers and data experts.

ObjectDataSource and GridView

Hello everyone,

I am using ASP.NET 2 and trying to bind a objectdatasource to a
gridview. By doing this the most common way by adding an
objectdatasource to the page and by using the wizard to connect to my
business logic everything works fine. The problem is that I find this
quite limited and I need to do some custom work with the parameters, so
I am trying to code everything by hand in the code behind.
From a security perspective, its not good at all to use the

ControlParameter without any kind of verification of the input (for
example
from a TextBox). Thats why I want to handle all parameters manually.

I have a GridView called "Vacancies". In the code behind I code my
ObjectDataSource and connects it to the GridView. The code below is
inside of an Onclick-event of a button named "Search".

ObjectDataSource dsVacancies = new ObjectDataSource();
dsVacancies.SelectMethod="SearchVacancy";";
dsVacancies.TypeName="BusinessProcess.Vacancy";

dsVacancies.SelectParameters.Clear();
dsVacancies.ID = "dsVacancies";

dsVacancies.SelectParameters.Add(new Parameter("countryId",
TypeCode.Int32, "1"));
dsVacancies.SelectParameters.Add(new Parameter("provincesIds",
TypeCode.String, ""));
dsVacancies.SelectParameters.Add(new Parameter("branchId",
TypeCode.Int32, "0"));
dsVacancies.SelectParameters.Add(new Parameter("freeText",
TypeCode.String, FreeText));

JobAdSearchResult.DataSource = dsVacancies;
JobSearchResult.DataBind();

I expected the GridView to populate the search result, but nothing
happens. No error message nor any data rows. I know that my
businesslogic works as I have filled my GridView without the
ObjectDataSource like this:

BusinessProcess.Vacancy vacancy = new BusinessProcess.Vacancy();
Vacancies.DataSouce = vacancy.SearchVacancy(1, "", 0, "");
Vacancies.DataBind();

But I want all the great functionality the ObjectDataSource provides.

What do I miss? I would appreciate if someone could point out some
mistakes in my code, or even better provide a complete example.

Thanks !

Eirik

Jan 19 '06 #1
0 1465

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
4
by: Anne Catterick | last post by:
Hi, I have an british ASP.Net 2.0 application which is doing what (should) be very simple. But I am having issues. On my page I have a GridView as follows (some tags excluded for easy...
3
by: mthomason | last post by:
I keep getting this error when trying to update records using an ObjectDataSource. I have seen others post similar errors...but I haven't found any solutions. ObjectDataSource...
2
by: Damon | last post by:
Help! Need this fixed ASAP. I have a GridView/DetailsView master/details form set up, with both bound to separate ObjectDataSource objects. Both the GridView and the DetailsView have a...
0
by: Northern | last post by:
Hello, I have some trouble to declare and instantiate dynamically an ObjectDataSource in the codebehind file. The idea is to bind the objectdatasource to a gridview and have automate sorting and...
1
by: syl | last post by:
Hello I am trying to create a "easy to use" gridview with filters (dropdownlist in headers), sorting...and much more.... In order to do that, i prefer to use a objectdatasource (ODS) beacause...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.