469,575 Members | 1,658 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

DataBinding a single record

Hi all

When I bind to multiple records I use a DataList. This allows the
web-designer to add code like <%#DataBinder.Eval(Container.DataItem,
"Name")%>

Whenever I want to retrieve a single record from the DB for editing I also
want to allow the designer to use the same technique. At the moment I am
still using a DataList for the single row, but this seems like the wrong
thing to do. How should I be doing it?
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com

Nov 18 '05 #1
3 2088
Pete

Databinding one record to DataList is still fine, especially when you want
to take advantage of its editing capabilities. Its data source enumerator
will enumerate its internal templated control just once. You still have
options, though. For example when you wanted to databind one record to let's
say Label control you could use:

<%# DataBinder.Eval(yourDataSet, "YourTable.Rows[0].YourColumn" %>

or using default DataView:

<%# DataBinder.Eval(yourDataSet,
"Tables[YourTable].DefaultView.[0].YourColumn" %>

You could use same technique to data bind to TextBox and allow editing by
updating yourDataSet.Tables["YourTable"].Rows[0]["YourColumn"] value with
your data adapter.

Different approach would be to construct business model (components) so you
could bind its exposed public properties even directly:

<%# MyComponent.MyProperty %>

HTH

Radek

"Peter Morris [Droopy Eyes Software]" <support@_nospam_.com> wrote in
message news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi all

When I bind to multiple records I use a DataList. This allows the
web-designer to add code like <%#DataBinder.Eval(Container.DataItem,
"Name")%>

Whenever I want to retrieve a single record from the DB for editing I also
want to allow the designer to use the same technique. At the moment I am
still using a DataList for the single row, but this seems like the wrong
thing to do. How should I be doing it?
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com

Nov 18 '05 #2
Thanks :-)

"RadekP" <ra***@aldec.com> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...
Pete

Databinding one record to DataList is still fine, especially when you want
to take advantage of its editing capabilities. Its data source enumerator
will enumerate its internal templated control just once. You still have
options, though. For example when you wanted to databind one record to let's say Label control you could use:

<%# DataBinder.Eval(yourDataSet, "YourTable.Rows[0].YourColumn" %>

or using default DataView:

<%# DataBinder.Eval(yourDataSet,
"Tables[YourTable].DefaultView.[0].YourColumn" %>

You could use same technique to data bind to TextBox and allow editing by
updating yourDataSet.Tables["YourTable"].Rows[0]["YourColumn"] value with
your data adapter.

Different approach would be to construct business model (components) so you could bind its exposed public properties even directly:

<%# MyComponent.MyProperty %>

HTH

Radek

"Peter Morris [Droopy Eyes Software]" <support@_nospam_.com> wrote in
message news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi all

When I bind to multiple records I use a DataList. This allows the
web-designer to add code like <%#DataBinder.Eval(Container.DataItem,
"Name")%>

Whenever I want to retrieve a single record from the DB for editing I also want to allow the designer to use the same technique. At the moment I am still using a DataList for the single row, but this seems like the wrong
thing to do. How should I be doing it?
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com


Nov 18 '05 #3
FYI .. The new upcoming edition of ASP.NET 2.0 ("Whidbey") does have a
special, neat control for databinding one record with full editing/inserting
capability - "DetailsView" ..

Radek

"Peter Morris [Droopy Eyes Software]" <support@_nospam_.com> wrote in
message news:ui**************@TK2MSFTNGP12.phx.gbl...
Thanks :-)

"RadekP" <ra***@aldec.com> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...
Pete

Databinding one record to DataList is still fine, especially when you want
to take advantage of its editing capabilities. Its data source enumerator will enumerate its internal templated control just once. You still have
options, though. For example when you wanted to databind one record to

let's
say Label control you could use:

<%# DataBinder.Eval(yourDataSet, "YourTable.Rows[0].YourColumn" %>

or using default DataView:

<%# DataBinder.Eval(yourDataSet,
"Tables[YourTable].DefaultView.[0].YourColumn" %>

You could use same technique to data bind to TextBox and allow editing by updating yourDataSet.Tables["YourTable"].Rows[0]["YourColumn"] value with your data adapter.

Different approach would be to construct business model (components) so

you
could bind its exposed public properties even directly:

<%# MyComponent.MyProperty %>

HTH

Radek

"Peter Morris [Droopy Eyes Software]" <support@_nospam_.com> wrote in
message news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi all

When I bind to multiple records I use a DataList. This allows the
web-designer to add code like <%#DataBinder.Eval(Container.DataItem,
"Name")%>

Whenever I want to retrieve a single record from the DB for editing I

also want to allow the designer to use the same technique. At the moment I am still using a DataList for the single row, but this seems like the wrong thing to do. How should I be doing it?
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Lamberti Fabrizio | last post: by
reply views Thread by Timothy White | last post: by
3 posts views Thread by Kevin Swanson | last post: by
1 post views Thread by Gary Shell | last post: by
13 posts views Thread by Mike | last post: by
2 posts views Thread by David C | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.