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
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? 3 1337
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 objectdatasource, e.g.
List<clsScannedDriverLicense> DriverLicenses = new
List<clsScannedDriverLicense>();
//this creates a generic collection for you that you can return from
//your BLL to the ObjectDataSource
DriverLicenses.Add(TheOneObjectThatYouHaveofType_c lsDriverLicense);
The your ObjectDataSource would look like that:
<asp:ObjectDataSource ID="odsDL" runat="server"
SelectMethod="OrdersByCustomer"
TypeName="YourBLL.UtiltiesClassName"
DataObjectTypeName="clsScannedDriverLicense">
</asp:ObjectDataSource>
--
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 ObjectDatasource 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?
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 objectdatasource, e.g.
List<clsScannedDriverLicense> DriverLicenses = new List<clsScannedDriverLicense>(); //this creates a generic collection for you that you can return from //your BLL to the ObjectDataSource DriverLicenses.Add(TheOneObjectThatYouHaveofType_c lsDriverLicense);
The your ObjectDataSource would look like that:
<asp:ObjectDataSource ID="odsDL" runat="server" SelectMethod="OrdersByCustomer" TypeName="YourBLL.UtiltiesClassName" DataObjectTypeName="clsScannedDriverLicense"> </asp:ObjectDataSource>
-- 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 ObjectDatasource 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?
You might be more interested in
"Binding" "DataBindings", 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.DataBindings.Add("Text",
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********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.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 ObjectDatasource 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?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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,...
|
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:
...
|
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...
|
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
...
|
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...
|
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
{...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |