473,808 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing an object to the Business Logic in my ObjectDataSourc e.SelectMethod

15 New Member
Hi, (ASP.NET question)

I'm using an ObjectDataSourc e on a DataGridView for a custom paging/sorting scenario. I implemented a method that gets the parameters for the paging (number of rows to retrieve, index of first row) and the SortingExpressi on.

In my page I have a lot of controls, used to determine which data I have to select from the DB. Since I'm using the custom paging, I had to make a static method that gets the above mentioned parameters. I used a static object - a collection of parameter values (retrieved from the page before calling DataBind). I now understand that this is bad practice - since everyone using the page is accessing the same static object of latest parameter values.

So now I need a way to pass that object into the static method. Any ideas on how to do it?
Mar 24 '08 #1
3 2577
frankiefrank
15 New Member
Anyone? Would still appreciate any help on the issue...

Thanks,
Frankie
Mar 30 '08 #2
balabaster
797 Recognized Expert Contributor
Um...passing an object into a method is the same as passing any other parameter....

Expand|Select|Wrap|Line Numbers
  1. Private Sub MyMethod(ByVal Param As Object)
  2.   Dim oClass As MyClass = CType(Param, MyClass)
  3.  
  4.   //Do stuff with oClass
  5.  
  6. End Sub
Is that what you meant?
Mar 30 '08 #3
frankiefrank
15 New Member
Um...passing an object into a method is the same as passing any other parameter....

Expand|Select|Wrap|Line Numbers
  1. Private Sub MyMethod(ByVal Param As Object)
  2.   Dim oClass As MyClass = CType(Param, MyClass)
  3.  
  4.   //Do stuff with oClass
  5.  
  6. End Sub
Is that what you meant?
Nope, I'm not THAT new to programming :)

Take a look at the ObjectDataSourc e property SelectMethod:
http://msdn2.microsoft.com/en-us/lib...ectmethod.aspx

The method name you provide for the ObjectDataSourc e is the name of a static method. When a DataBind occurs the DataGridView (bound the ObjectDataSourc e) calls the Select method to get data - but since it's Static (required) I can't access my non-static members (with this keyword.

Hope my problem is clearer now...
Apr 7 '08 #4

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

Similar topics

2
3767
by: ulrich schumacher | last post by:
Hi ASP.NET 2.0 Professionals, I've got a question concerning the new ASP.NET 2.0 DataBinding with object oriented business classes: Example: There are two business classes in my domain model: public class Language
1
2147
by: thzero | last post by:
Is there any way to do this without using the ObjectDataSource? (Apologies for the long post) I have a simple data object: public class TestDO { public TestDO() {} public ID { get; set; } public Name { get; set; } public Description { get; set; }
3
1349
by: John Bailey | last post by:
I have a page with a business object that is populated by parsing input from the page (specifically a scanned drivers license). I was hoping that I could display the results using a details view or bound to labels in a table. In .Net 1.1, I would have just bound the individual text fields to the object. This does not apear to be an option in .Net 2.0. The ObjectDatasource seemed to be what I wanted (after all, I am binding to an...
0
1892
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 paging. The objectdatasource SelectMethod returns a dataview. When my objectdatasource is declared in the codebehind, sorting is not working and i receive following error when clicking on a datagrid's column header. I made the same test...
0
1197
by: Evert Wiesenekker | last post by:
I am struggling with the following situation : Suppose I have an Object model of a house. The house can contain 0 or more chairs. Lets say the House class looks like this: class House { private List<Chair_chairs; public List<ChairChairs {
2
6787
by: Olivier Matrot | last post by:
Hello, I'm using a gridview with objectdatasource and custom objects collections SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters. This is working fine. But I have a problem with the object that is passed back to the update method. It contains some of the properties of the original object sent during the SELECT method, but is missing others ! How can I ensure that all original object properties not modified are...
8
11974
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property which is not a string, for example a custom type Address which contains properties such as StreetAddress, City, County, Country etc how do i bind to those properties on the same form view? I have tried doing Bind("Address.StreetAddress") but...
1
258
by: =?Utf-8?B?UGF1bCBT?= | last post by:
Hi I have created a collection of business objects in a seperate dll, which I have then added to my web project. However it does not show up in list of Website Data Sources. I need to Data Source to be able to design my Report (MS Reporting) I have added a ObjectDataSource to a page <asp:ObjectDataSource ID="ObjectDataSource3" runat="server"
0
2148
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a ListBox server control named "lb_dates" with a SelectionMode of "Multiple". The user can select multiple dates from the listbox. I have ObjectDataSource named "ods_rfq" with a ControlParameter that has a ControlID that points to "lb_dates". The PropertyName of the ControlParameter is "SelectedValue". The user selects two dates from the ListBox. I am trying to pass BOTH selected values of the ListBox to a SelectMethod of
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.