Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ObjectDataSource and GridView

Reply
Thread Tools

ObjectDataSource and GridView

 
 
Eiriken
Guest
Posts: n/a
 
      01-19-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Record count required when using GridView and ObjectDataSource J055 ASP .Net 10 03-18-2009 10:57 AM
Gridview,CheckboxList and ObjectDataSource avital ASP .Net 0 11-15-2006 10:21 AM
Gridview and ObjectDataSource with Custom object : update problem Olivier Matrot ASP .Net 2 10-02-2006 02:59 AM
GridView, ObjectDataSource and SortDirection codefragment@googlemail.com ASP .Net 1 05-03-2006 01:59 PM
ObjectDataSource method as another ObjectDataSource David Thielen ASP .Net Web Controls 3 03-23-2006 01:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57