Datasource property missing for ASP.NET Textbox in VS.NET 2005

K

Ken Varn

I have just started using VS.NET 2005 after using VS.NET 2003. One of the
things that I noticed is that in ASP.NET, the DataSource property for
TextBoxes and other web controls is no longer available from 2003 to 2005.
Is there some other method available to bind TextBoxes that I am not seeing?

I have seen some articles on the web stating that you can only bind to grid
and list controls. Seems like a step backward to me. Why would the
databinding functionality be removed from TextBox controls or any control
for that matter? This WAS a very useful feature. The control still has a
DataBind() method, but no way to specify DataSource any longer.

Maybe there is some other way to bind controls better than before, but I
have not found it. The closest thing I found was the Expression builder,
but it is very limited on what can be bound.



--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
G

Guest

Hi Ken,

This is quite logical as TextBoxes are usually used inside other data bound
controls' templates. This control has just one property that is mostly being
set - Text. So what's the point of assigning datasource to set the text if
it's easier to write myTextBox.Text = dataRow["Column"].ToString()
In addition, it would be mandatory to set datasource of every's text box on
a web form. Imagine you have 10 textboxes, each one represents column's value
for a single record (i.e. firstname, lastname, address, etc.). Is it just
better / easier / faster to group these boxes in one bound control (see
asp.net 2.0 new controls FormView, DetailsView) and assign datasource to it
and call DataBind()

<asp:FormView runat="server" ID="fv">
<itemTemplate>
<asp:TextBox runat="server" ID="firstName" Text='<%# Eval("FirstName") %>'/>
<asp:TextBox runat="server" ID="lastName" Text='<%# Eval("LastName") %>'/>
</itemTemplate>

One more thing. ASP.NET supports enumerable data sources, meaning a record
(an object, or a value) must be wrapped to a IList implementator to support
binding. And also it would be quite inefficient from coding point of view to
assign datasource for every single control:

textBox1.DataSource = whatever1;
textBox1.DataBind();
textBox2.DataSource = whatever2;
textBox2.DataBind();
textBox3.DataSource = whatever3;
textBox3.DataBind();

It's better to do it collectively.

Best Regards
 
K

Ken Varn

Although I may understand the reasoning behind your explanation, I still
don't understand its justification. So-what if it is the same as assigning
the text value? The thing that is disturbing to me is that this was
available in the older framework and was removed without the slightest hint
of it being deprecated. Thus, any older ASP.NET 1.1 pages that may have
used it are now incompatible with the 2.0 framework if they are to be
migrated.

This is an all-too-familiar problem with Microsoft in that they change
things at the drop of a hat without any regard for downward compatibility,
especially on a .NET Framework that is only one version newer than when this
feature was available.

From purely a coding perspective, it probably does not make sense to have
it, but when using the VS visual designer, it was much more beneficial in
that you could just click and select items to be bound without having to
write the code to do it. And now with two-way binding, it would be even
more beneficial. It just seems a bit odd to remove a piece of functionality
just because someone thought it was not necessary.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken,

This is quite logical as TextBoxes are usually used inside other data bound
controls' templates. This control has just one property that is mostly being
set - Text. So what's the point of assigning datasource to set the text if
it's easier to write myTextBox.Text = dataRow["Column"].ToString()
In addition, it would be mandatory to set datasource of every's text box on
a web form. Imagine you have 10 textboxes, each one represents column's
value
for a single record (i.e. firstname, lastname, address, etc.). Is it just
better / easier / faster to group these boxes in one bound control (see
asp.net 2.0 new controls FormView, DetailsView) and assign datasource to it
and call DataBind()

<asp:FormView runat="server" ID="fv">
<itemTemplate>
<asp:TextBox runat="server" ID="firstName" Text='<%# Eval("FirstName") %>'/>
<asp:TextBox runat="server" ID="lastName" Text='<%# Eval("LastName") %>'/>
</itemTemplate>

One more thing. ASP.NET supports enumerable data sources, meaning a record
(an object, or a value) must be wrapped to a IList implementator to support
binding. And also it would be quite inefficient from coding point of view to
assign datasource for every single control:

textBox1.DataSource = whatever1;
textBox1.DataBind();
textBox2.DataSource = whatever2;
textBox2.DataBind();
textBox3.DataSource = whatever3;
textBox3.DataBind();

It's better to do it collectively.

Best Regards
 
G

Guest

Howdy,

I just realised, textbox didn't have datasource property in 1.1 anyway, it's
working exactly the same as it was. And replying your resoning, i can't
really see the point in assigning a datesource to every single box on the
form, it's better to do it colectively.

Best regards
--
Milosz


Ken Varn said:
Although I may understand the reasoning behind your explanation, I still
don't understand its justification. So-what if it is the same as assigning
the text value? The thing that is disturbing to me is that this was
available in the older framework and was removed without the slightest hint
of it being deprecated. Thus, any older ASP.NET 1.1 pages that may have
used it are now incompatible with the 2.0 framework if they are to be
migrated.

This is an all-too-familiar problem with Microsoft in that they change
things at the drop of a hat without any regard for downward compatibility,
especially on a .NET Framework that is only one version newer than when this
feature was available.

From purely a coding perspective, it probably does not make sense to have
it, but when using the VS visual designer, it was much more beneficial in
that you could just click and select items to be bound without having to
write the code to do it. And now with two-way binding, it would be even
more beneficial. It just seems a bit odd to remove a piece of functionality
just because someone thought it was not necessary.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken,

This is quite logical as TextBoxes are usually used inside other data bound
controls' templates. This control has just one property that is mostly being
set - Text. So what's the point of assigning datasource to set the text if
it's easier to write myTextBox.Text = dataRow["Column"].ToString()
In addition, it would be mandatory to set datasource of every's text box on
a web form. Imagine you have 10 textboxes, each one represents column's
value
for a single record (i.e. firstname, lastname, address, etc.). Is it just
better / easier / faster to group these boxes in one bound control (see
asp.net 2.0 new controls FormView, DetailsView) and assign datasource to it
and call DataBind()

<asp:FormView runat="server" ID="fv">
<itemTemplate>
<asp:TextBox runat="server" ID="firstName" Text='<%# Eval("FirstName") %>'/>
<asp:TextBox runat="server" ID="lastName" Text='<%# Eval("LastName") %>'/>
</itemTemplate>

One more thing. ASP.NET supports enumerable data sources, meaning a record
(an object, or a value) must be wrapped to a IList implementator to support
binding. And also it would be quite inefficient from coding point of view to
assign datasource for every single control:

textBox1.DataSource = whatever1;
textBox1.DataBind();
textBox2.DataSource = whatever2;
textBox2.DataBind();
textBox3.DataSource = whatever3;
textBox3.DataBind();

It's better to do it collectively.

Best Regards
 
K

Ken Varn

Man do I feel stupid. I could have sworn that it was in the 1.1 framework.
I think that the wording in VS.NET was changed from DataBindings to
Expressions. Maybe that is what threw me off. One other explanation could
be that someone went back in time and altered my past perception of ASP.NET
1.1. Maybe not.

Anyhow, I still think that two-way databinding would be nice for entry
fields. It would minimize some coding by only specifying the bound data in
one portion of code rather than in two (saving and loading).

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Howdy,

I just realised, textbox didn't have datasource property in 1.1 anyway, it's
working exactly the same as it was. And replying your resoning, i can't
really see the point in assigning a datesource to every single box on the
form, it's better to do it colectively.

Best regards
--
Milosz


Ken Varn said:
Although I may understand the reasoning behind your explanation, I still
don't understand its justification. So-what if it is the same as
assigning
the text value? The thing that is disturbing to me is that this was
available in the older framework and was removed without the slightest
hint
of it being deprecated. Thus, any older ASP.NET 1.1 pages that may have
used it are now incompatible with the 2.0 framework if they are to be
migrated.

This is an all-too-familiar problem with Microsoft in that they change
things at the drop of a hat without any regard for downward compatibility,
especially on a .NET Framework that is only one version newer than when
this
feature was available.

From purely a coding perspective, it probably does not make sense to have
it, but when using the VS visual designer, it was much more beneficial in
that you could just click and select items to be bound without having to
write the code to do it. And now with two-way binding, it would be even
more beneficial. It just seems a bit odd to remove a piece of
functionality
just because someone thought it was not necessary.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken,

This is quite logical as TextBoxes are usually used inside other data
bound
controls' templates. This control has just one property that is mostly
being
set - Text. So what's the point of assigning datasource to set the text if
it's easier to write myTextBox.Text = dataRow["Column"].ToString()
In addition, it would be mandatory to set datasource of every's text box
on
a web form. Imagine you have 10 textboxes, each one represents column's
value
for a single record (i.e. firstname, lastname, address, etc.). Is it just
better / easier / faster to group these boxes in one bound control (see
asp.net 2.0 new controls FormView, DetailsView) and assign datasource to
it
and call DataBind()

<asp:FormView runat="server" ID="fv">
<itemTemplate>
<asp:TextBox runat="server" ID="firstName" Text='<%# Eval("FirstName")
%>'/>
<asp:TextBox runat="server" ID="lastName" Text='<%# Eval("LastName") %>'/>
</itemTemplate>

One more thing. ASP.NET supports enumerable data sources, meaning a record
(an object, or a value) must be wrapped to a IList implementator to
support
binding. And also it would be quite inefficient from coding point of view
to
assign datasource for every single control:

textBox1.DataSource = whatever1;
textBox1.DataBind();
textBox2.DataSource = whatever2;
textBox2.DataBind();
textBox3.DataSource = whatever3;
textBox3.DataBind();

It's better to do it collectively.

Best Regards
 
G

Guest

No probs Ken ;]. Two way binding is already there, check <%# Bind() %> out.

Regards
--
Milosz


Ken Varn said:
Man do I feel stupid. I could have sworn that it was in the 1.1 framework.
I think that the wording in VS.NET was changed from DataBindings to
Expressions. Maybe that is what threw me off. One other explanation could
be that someone went back in time and altered my past perception of ASP.NET
1.1. Maybe not.

Anyhow, I still think that two-way databinding would be nice for entry
fields. It would minimize some coding by only specifying the bound data in
one portion of code rather than in two (saving and loading).

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Howdy,

I just realised, textbox didn't have datasource property in 1.1 anyway, it's
working exactly the same as it was. And replying your resoning, i can't
really see the point in assigning a datesource to every single box on the
form, it's better to do it colectively.

Best regards
--
Milosz


Ken Varn said:
Although I may understand the reasoning behind your explanation, I still
don't understand its justification. So-what if it is the same as
assigning
the text value? The thing that is disturbing to me is that this was
available in the older framework and was removed without the slightest
hint
of it being deprecated. Thus, any older ASP.NET 1.1 pages that may have
used it are now incompatible with the 2.0 framework if they are to be
migrated.

This is an all-too-familiar problem with Microsoft in that they change
things at the drop of a hat without any regard for downward compatibility,
especially on a .NET Framework that is only one version newer than when
this
feature was available.

From purely a coding perspective, it probably does not make sense to have
it, but when using the VS visual designer, it was much more beneficial in
that you could just click and select items to be bound without having to
write the code to do it. And now with two-way binding, it would be even
more beneficial. It just seems a bit odd to remove a piece of
functionality
just because someone thought it was not necessary.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken,

This is quite logical as TextBoxes are usually used inside other data
bound
controls' templates. This control has just one property that is mostly
being
set - Text. So what's the point of assigning datasource to set the text if
it's easier to write myTextBox.Text = dataRow["Column"].ToString()
In addition, it would be mandatory to set datasource of every's text box
on
a web form. Imagine you have 10 textboxes, each one represents column's
value
for a single record (i.e. firstname, lastname, address, etc.). Is it just
better / easier / faster to group these boxes in one bound control (see
asp.net 2.0 new controls FormView, DetailsView) and assign datasource to
it
and call DataBind()

<asp:FormView runat="server" ID="fv">
<itemTemplate>
<asp:TextBox runat="server" ID="firstName" Text='<%# Eval("FirstName")
%>'/>
<asp:TextBox runat="server" ID="lastName" Text='<%# Eval("LastName") %>'/>
</itemTemplate>

One more thing. ASP.NET supports enumerable data sources, meaning a record
(an object, or a value) must be wrapped to a IList implementator to
support
binding. And also it would be quite inefficient from coding point of view
to
assign datasource for every single control:

textBox1.DataSource = whatever1;
textBox1.DataBind();
textBox2.DataSource = whatever2;
textBox2.DataBind();
textBox3.DataSource = whatever3;
textBox3.DataBind();

It's better to do it collectively.

Best Regards
--
Milosz


Ken Varn said:
I have just started using VS.NET 2005 after using VS.NET 2003. One of
the
things that I noticed is that in ASP.NET, the DataSource property for
TextBoxes and other web controls is no longer available from 2003 to
2005.
Is there some other method available to bind TextBoxes that I am not
seeing?

I have seen some articles on the web stating that you can only bind to
grid
and list controls. Seems like a step backward to me. Why would the
databinding functionality be removed from TextBox controls or any
control
for that matter? This WAS a very useful feature. The control still has
a
DataBind() method, but no way to specify DataSource any longer.

Maybe there is some other way to bind controls better than before, but I
have not found it. The closest thing I found was the Expression
builder,
but it is very limited on what can be bound.



--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top