473,943 Members | 13,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding an object to a table

I've created objects before that I could bind to UI controls, but now
I want to do sort of the opposite. I want to bind an object to a
table such that the current rows columns map to properties of the same
name in the object.

I have been halfway successful by inheriting from the
BindableCompone nt class and then using code such as
court.DataBindi ngs.Add("Column Name1", codesCourtBindi ngSource,
"ColumnName 1");

....where court is my object, codesCourtBindi ngSource has a DataSet as
its DataSource and the table name as it's DataMember.

However, this means I have to write a line of code for every column.
I have done bindings before where I could specify an empty string for
the property name and datamember, and it binds all the names which
match. In this scenario though, I haven't had any success with this:
court.DataBindi ngs.Add("", codesCourtBindi ngSource, "");

I wanted to implement IBindableCompon ent so that I could intercept
calls and see what was going on under the hood with this binding
stuff, but I have no idea how to create this implementation and
haven't found any fleshed out examples.

If anyone has links to examples of implementing IBindableCompon ent,
I'd be interested.

Aug 15 '07 #1
3 3767
OK - I now understand what you want to do...

I reemmber reading a good article on object-to-object (non-UI) binding
a while ago, which used server-side background processing as an
example ... I'll see if I can find it, but I've had a quick hunt and I
can't spot it... but the MSDN articles are normally quite good for
examples (IMO)...

Marc
Aug 16 '07 #2
On Aug 16, 3:01 am, "Marc Gravell" <marc.grav...@g mail.comwrote:
OK - I now understand what you want to do...

I reemmber reading a good article on object-to-object (non-UI) binding
a while ago, which used server-side background processing as an
example ... I'll see if I can find it, but I've had a quick hunt and I
can't spot it... but the MSDN articles are normally quite good for
examples (IMO)...

Marc
Thanks Marc. I found a post with an IBindableCompon ent
implementation:
http://blogs.msdn.com/jfoscoding/arc...23/507164.aspx

I was able to emulate this and it works well for a regular object, but
I never figured out how to get it to work without specifying a binding
for every single property. Maybe I will make an AutoBind function
that reflectively matches up properties and creates bindings for each
one so that I don't have to hardcode the property names.

There are several MSDN articles on binding objects to server side
controls for ASP.NET, but again that is using the objects as a
datasource instead of the object using a dataset as the datasource.

-Aaron

Aug 16 '07 #3
On Aug 16, 3:01 am, "Marc Gravell" <marc.grav...@g mail.comwrote:
OK - I now understand what you want to do...

I reemmber reading a good article on object-to-object (non-UI) binding
a while ago, which used server-side background processing as an
example ... I'll see if I can find it, but I've had a quick hunt and I
can't spot it... but the MSDN articles are normally quite good for
examples (IMO)...

Marc
Thanks Marc. I found a post with an IBindableCompon ent
implementation:
http://blogs.msdn.com/jfoscoding/arc...23/507164.aspx

I was able to emulate this and it works well for a regular object, but
I never figured out how to get it to work without specifying a binding
for every single property. Maybe I will make an AutoBind function
that reflectively matches up properties and creates bindings for each
one so that I don't have to hardcode the property names.

There are several MSDN articles on binding objects to server side
controls for ASP.NET, but again that is using the objects as a
datasource instead of the object using a dataset as the datasource.

-Aaron

Aug 16 '07 #4

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

Similar topics

3
2962
by: Jesse | last post by:
Hi All, I've been working on a form that has several bound controls that all link to one table in a dataset. In the table, there is a column for the filename of jpeg images related to each record. I have a combobox which displays the key for each record so that the user can select an item and all the other controls update. So far i have the combobox, a label and a textbox all bound and working correctly when a user selects an item. ...
14
4330
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs hundreds of lines of code to format a Word document in a very specific way. Because my clients have various versions of Word, the problem of broken references comes up. I wish Microsoft had implemented a reasonable solution, so that VBA could do...
2
2325
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl AmazonWebService.com.amazon.webservices.Item As you can see from the code snippets below it has public member variables rather than public Properties. When I use <%# DataBinder.Eval(Container.DataItem, "ASIN") %> syntax in...
11
4677
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set the information I need programmatically, but what about the databind property I just don't understand it's value.
1
2644
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from Products table.
0
4824
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having manually inserted a row in the table bound to the Combo box. The InsertAt Method of adding a row just does not work. Hope this helps anyone with this problem. john
4
4634
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
4
4935
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString; //open connection SqlConnection m_conn = new SqlConnection("Server=server; Database=database; UId=username; Pwd=password");
0
1565
by: pmeems | last post by:
This is my first post to this group. So I say hello to all members. I'm in the process of converting my C# early binding of MS Word to late binding so I don't have any trouble running my application on a different pc (using a different version of MS Word). I'm still struggling with converting these lines of code: Object oUnit = Word.WdUnits.wdCell; _WordDoc.ActiveWindow.Selection.MoveRight(ref oUnit, ref _missing, ref _missing);
1
2115
by: GS | last post by:
I am perplexed . I thought it is easy to fix the binding error on cvtDtFrom. I only used the cvtDtFrom a couple of places but I found out the error occurred before form loading. I tried searching in the solution for cvtDtFrom but failed to find the culprit. tried using clue from stack trace, searching for DataGridview and variations of view.datacon... no luck, Even tried searching all files for the sub main, I failed to find...
0
10142
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
11538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11133
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
8228
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
7392
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
6311
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4913
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
2
4515
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3516
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.