I am using ASP.NET 2 and trying to bind a objectdatasourc e to a
gridview. By doing this the most common way by adding an
objectdatasourc e 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
ControlParamete r 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
ObjectDataSourc e and connects it to the GridView. The code below is
inside of an Onclick-event of a button named "Search".
ObjectDataSourc e dsVacancies = new ObjectDataSourc e();
dsVacancies.Sel ectMethod="Sear chVacancy";";
dsVacancies.Typ eName="Business Process.Vacancy ";
dsVacancies.Sel ectParameters.C lear();
dsVacancies.ID = "dsVacancie s";
dsVacancies.Sel ectParameters.A dd(new Parameter("coun tryId",
TypeCode.Int32, "1"));
dsVacancies.Sel ectParameters.A dd(new Parameter("prov incesIds",
TypeCode.String , ""));
dsVacancies.Sel ectParameters.A dd(new Parameter("bran chId",
TypeCode.Int32, "0"));
dsVacancies.Sel ectParameters.A dd(new Parameter("free Text",
TypeCode.String , FreeText));
JobAdSearchResu lt.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
ObjectDataSourc e like this:
BusinessProcess .Vacancy vacancy = new BusinessProcess .Vacancy();
Vacancies.DataS ouce = vacancy.SearchV acancy(1, "", 0, "");
Vacancies.DataB ind();
But I want all the great functionality the ObjectDataSourc e 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