473,799 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can you still databind to a single object in ASP .Net 2.0?

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
ObjectDatasourc e seemed to be what I wanted (after all, I am binding to an
object), but it requires a collection. Is there any way to bind to a a
single object?

I also tried to go into the html source and set the text properties to the
object values using the <%= %> syntax and the Eval syntax. These also did
not work, although I can insert <%= %>this directly into the html and it
displays the values. I may be setting other values at the server for these,
so it would be more advantageous for me to use a server control if possible.

I seems silly that something so simple to do in .Net 1.1 would be such a
pain in .Net 2.0, so I must be missing something. Does anyone know how to do
it?
Mar 29 '06 #1
3 1347
Hi John,

In ASP.NET2.0 you can use the generic collections to make this single object
a list of only one object in it that you can databind to any server control
using the objectdatasourc e, e.g.

List<clsScanned DriverLicense> DriverLicenses = new
List<clsScanned DriverLicense>( );
//this creates a generic collection for you that you can return from
//your BLL to the ObjectDataSourc e
DriverLicenses. Add(TheOneObjec tThatYouHaveofT ype_clsDriverLi cense);
The your ObjectDataSourc e would look like that:

<asp:ObjectData Source ID="odsDL" runat="server"
SelectMethod="O rdersByCustomer "
TypeName="YourB LL.UtiltiesClas sName"
DataObjectTypeN ame="clsScanned DriverLicense">
</asp:ObjectDataS ource>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"John Bailey" wrote:
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
ObjectDatasourc e seemed to be what I wanted (after all, I am binding to an
object), but it requires a collection. Is there any way to bind to a a
single object?

I also tried to go into the html source and set the text properties to the
object values using the <%= %> syntax and the Eval syntax. These also did
not work, although I can insert <%= %>this directly into the html and it
displays the values. I may be setting other values at the server for these,
so it would be more advantageous for me to use a server control if possible.

I seems silly that something so simple to do in .Net 1.1 would be such a
pain in .Net 2.0, so I must be missing something. Does anyone know how to do
it?

Mar 29 '06 #2
Okay, but this seems a little bit silly. I will need to create a method that
returns this collection for the sole purpose of databinding the object.

In 1.1 you could databind to anything, even other controls of the page. It
wasn't uncommon to bind the visibility property of a panel to a radio button
or other control on the page. From what you are telling me, to do the same
thing in .Net 2.0 I would have to create a method that would wrap the page in
a generic collection and return it to create the same kind of binding.

This seems like a step backwards.

"Phillip Williams" wrote:
Hi John,

In ASP.NET2.0 you can use the generic collections to make this single object
a list of only one object in it that you can databind to any server control
using the objectdatasourc e, e.g.

List<clsScanned DriverLicense> DriverLicenses = new
List<clsScanned DriverLicense>( );
//this creates a generic collection for you that you can return from
//your BLL to the ObjectDataSourc e
DriverLicenses. Add(TheOneObjec tThatYouHaveofT ype_clsDriverLi cense);
The your ObjectDataSourc e would look like that:

<asp:ObjectData Source ID="odsDL" runat="server"
SelectMethod="O rdersByCustomer "
TypeName="YourB LL.UtiltiesClas sName"
DataObjectTypeN ame="clsScanned DriverLicense">
</asp:ObjectDataS ource>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"John Bailey" wrote:
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
ObjectDatasourc e seemed to be what I wanted (after all, I am binding to an
object), but it requires a collection. Is there any way to bind to a a
single object?

I also tried to go into the html source and set the text properties to the
object values using the <%= %> syntax and the Eval syntax. These also did
not work, although I can insert <%= %>this directly into the html and it
displays the values. I may be setting other values at the server for these,
so it would be more advantageous for me to use a server control if possible.

I seems silly that something so simple to do in .Net 1.1 would be such a
pain in .Net 2.0, so I must be missing something. Does anyone know how to do
it?

Mar 29 '06 #3

You might be more interested in

"Binding" "DataBindin gs", which is more MVC, more work, but allows the
single entity situaiton you describe.

http://www.west-wind.com/presentatio...atabinding.asp
...

I do the databindings alot in winforms apps ......... and is worth the price
you pay.
For the web, I'm up in the air about it.

2.0 adds the ability to handle "Null" values with databinding, which is a
HUGE step and upgrade from 1.1.

...

example of the nulls:
Binding titleIdBinding =_ txtTitleId.Data Bindings.Add("T ext",
Me.m_model, "TitleId");

'Improved in .NET 2.0 //
http://msdn2.microsoft.com/library/y...us,vs.80).aspx
'titleIdBinding .NullValue = "Type a TitleID Here";
"John Bailey" <Jo********@dis cussions.micros oft.com> wrote in message
news:60******** *************** ***********@mic rosoft.com...
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
ObjectDatasourc e seemed to be what I wanted (after all, I am binding to an
object), but it requires a collection. Is there any way to bind to a a
single object?

I also tried to go into the html source and set the text properties to the
object values using the <%= %> syntax and the Eval syntax. These also did
not work, although I can insert <%= %>this directly into the html and it
displays the values. I may be setting other values at the server for these, so it would be more advantageous for me to use a server control if possible.
I seems silly that something so simple to do in .Net 1.1 would be such a
pain in .Net 2.0, so I must be missing something. Does anyone know how to do it?

Mar 29 '06 #4

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

Similar topics

3
12021
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the DataTable, then I discovered the asp:Table has a DataBind method. But the method takes no args and so I'm confused how to use it. Is there a link to see how DataBind works for asp:Table? Should I just use my own code anyway? Thanks... Here's my...
1
1899
by: Thomas Jespersen | last post by:
Hello How do I databind a ASP.NET Texbox to a custom object. I a WinForm I do it like this: Dim myCustomerObject As Customer() Private Sub CreateNewCustomer myCustomerObject = New Customer() myCustomerObject.FirstName = "Thomas"
10
11611
by: aualias | last post by:
This seems like such a lame question, but how do you bind to a CheckBox with ASP.NET? With Windows Forms there is a DataBindings collection. I do not see it with the web version of the control, but there is a DataBinding event. Thanks. AU
10
5342
by: Assimalyst | last post by:
Hi, I'm attempting to use a data reader to load data from a single table, tblCountry, with two columns, countryNo (the Key) and countryName, into a DropDownList box. Here's the code: protected System.Data.SqlClient.SqlConnection conn; protected System.Data.SqlClient.SqlDataReader drCountry;
16
1795
by: Richard | last post by:
Hi, I am passing a structure to a subroutine where the passed parameter has been declared as ByVal. However, changes made to the passed variable inside the subroutine flow through to the actual variable that has been passed over, even though with ByVal this should not happen. Has anybody else discovered this or am I doing completely wrong /
7
1132
by: Tmuld | last post by:
Hello, I was looking at the example provided on: http://www.4guysfromrolla.com/webtech/072101-1.2.shtml for paging. I am using Visual Studio 2003 - Microsoft Development Environment 2003 For paging the page url mentions setting properties to be set as:
1
2943
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to call databind (sender.DataBind(); in NeedList_ItemCommand method). The error message is at the bottom of this message (System.NullReferenceException) Can anyone else see anything wrong with this? (I've included all relevant code, stored...
2
2129
by: Joe | last post by:
I want to bind to the property Caption but can't. I get the exception: "Cannot bind to property or column Caption on DataSource. Parameter name: dataMember" public class Test : CollectionBase { private string caption; public string Caption {
0
4282
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
9685
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
10249
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...
0
10025
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
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
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4138
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
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2937
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.