473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP:Table Problems

I am confused about the way in which asp:table objects work. When a control
is within an asp table it generally appears to be in the scope of the tables
parent control. E.g. if i have a page that consists of an asp table called
MyTable containing a textbox control call MyTextBox then i can access
MyTextBox directly from the PageLoad event handler without having to use
MyTable.FindControl(MyTextBox). MyTextBox can also be used for a control
paramter for an DataSourcecontrol that is outside of MyTable. In short ASP
table objects do not seem to impose the same kind of scoping restriction that
apply to data bound control such as DetalsView or GridvView.

However i have found that if you use an asp table object within a
TemplateField then place a control, that has been bound using <%#
Bind("FieldName") %syntax, within that table, the two way databinding does
not work. It works as far as retreiving that data is concerned but as suu as
you try to insert or update data it treats all the values as null. If you
move the data bound controls outside tha asp table then updating and
inserting work fine. Deleting works fine even within the table.

I have got round this by using the ItemUpdating and ItemInserting event
handlers and pulling tha value out of the controls within the table and
putting them in e.NewValue and e.Values respectively.

What am i missing, why does two way databinding not work within an asp table
object.
Jul 17 '06 #1
2 2359
Hi,

it is basically the same thing. GridView and DetailsView are, yes, naming
containers where they "take" ownership of their child controls by being
their naming containers. What comes to databinding, with GridView when you
databind Container refers to the item of the control to which you databind
e.g GridViewRow. asp:table does not provide naming scopes, and it neither
has separare items to which you bind (e.g they'd be TableRows if comparing
semantically to GridView)

Basically asp:table is not databound control like GridView etc are, and
therefore two-way databinding doesn't work.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"clickon" <cl*****@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
>I am confused about the way in which asp:table objects work. When a
control
is within an asp table it generally appears to be in the scope of the
tables
parent control. E.g. if i have a page that consists of an asp table
called
MyTable containing a textbox control call MyTextBox then i can access
MyTextBox directly from the PageLoad event handler without having to use
MyTable.FindControl(MyTextBox). MyTextBox can also be used for a control
paramter for an DataSourcecontrol that is outside of MyTable. In short
ASP
table objects do not seem to impose the same kind of scoping restriction
that
apply to data bound control such as DetalsView or GridvView.

However i have found that if you use an asp table object within a
TemplateField then place a control, that has been bound using <%#
Bind("FieldName") %syntax, within that table, the two way databinding
does
not work. It works as far as retreiving that data is concerned but as suu
as
you try to insert or update data it treats all the values as null. If you
move the data bound controls outside tha asp table then updating and
inserting work fine. Deleting works fine even within the table.

I have got round this by using the ItemUpdating and ItemInserting event
handlers and pulling tha value out of the controls within the table and
putting them in e.NewValue and e.Values respectively.

What am i missing, why does two way databinding not work within an asp
table
object.

Jul 17 '06 #2
Perhaps i wasn't being clear as you seem to have missed my point entirely. I
am not trying to bind data to an ASP table. The asp table is within a
templatefield inside a databound FormView control. Within the asp table are
a number of textboxes DDLs etc bound to various fields using the <%#
Bind("FieldName") %syntax. Data binding works perfectly for retreiving
data, but when i try to update or insert data i get an SQL exception telling
me various fields are null when they are not suposed to be. The controls
that are bound to these fields are not null at this point. If i move
textbox, ddls etc outside the asp table then the updates and inserts work
fine. Deleting works fine either way. I have tested that this occurs to
both a FormView and a DetailsView.

For clarity there are two examples below.

This markup does not work ...

<asp:FormView ID="MyformView" runat="server" DataKeyNames="SomeKeyfield"
DataSourceID="SomeDataSource">
<EditItemTemplate>
<asp:Table ID="tblEditSelectedRoute" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox ID="MyTextBox" runat="server" Text='<%# Bind("SomeField") %>
</asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</EditItemTemplate>

This markup works fine...

<asp:FormView ID="MyformView" runat="server" DataKeyNames="SomeKeyfield"
DataSourceID="SomeDataSource">
<EditItemTemplate>
<asp:TextBox ID="MyTextBox" runat="server" Text='<%# Bind("SomeField") %>
</asp:TextBox>
<asp:Table ID="tblEditSelectedRoute" runat="server">
<asp:TableRow>
<asp:TableCell>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</EditItemTemplate>

"Teemu Keiski" wrote:
Hi,

it is basically the same thing. GridView and DetailsView are, yes, naming
containers where they "take" ownership of their child controls by being
their naming containers. What comes to databinding, with GridView when you
databind Container refers to the item of the control to which you databind
e.g GridViewRow. asp:table does not provide naming scopes, and it neither
has separare items to which you bind (e.g they'd be TableRows if comparing
semantically to GridView)

Basically asp:table is not databound control like GridView etc are, and
therefore two-way databinding doesn't work.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"clickon" <cl*****@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
I am confused about the way in which asp:table objects work. When a
control
is within an asp table it generally appears to be in the scope of the
tables
parent control. E.g. if i have a page that consists of an asp table
called
MyTable containing a textbox control call MyTextBox then i can access
MyTextBox directly from the PageLoad event handler without having to use
MyTable.FindControl(MyTextBox). MyTextBox can also be used for a control
paramter for an DataSourcecontrol that is outside of MyTable. In short
ASP
table objects do not seem to impose the same kind of scoping restriction
that
apply to data bound control such as DetalsView or GridvView.

However i have found that if you use an asp table object within a
TemplateField then place a control, that has been bound using <%#
Bind("FieldName") %syntax, within that table, the two way databinding
does
not work. It works as far as retreiving that data is concerned but as suu
as
you try to insert or update data it treats all the values as null. If you
move the data bound controls outside tha asp table then updating and
inserting work fine. Deleting works fine even within the table.

I have got round this by using the ItemUpdating and ItemInserting event
handlers and pulling tha value out of the controls within the table and
putting them in e.NewValue and e.Values respectively.

What am i missing, why does two way databinding not work within an asp
table
object.


Jul 17 '06 #3

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

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
2
by: Kevin | last post by:
I am just learning asp.net and ran into a problem that I have not been able to resolve. I have a web form with an html table that houses an asp:label, asp:textbox and asp:button within. I had the...
3
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...
4
by: coleenholley | last post by:
I asked the question yesterday: > HI All :-) > > I don't know if I will be able to do this type of formatting, but what I > need to do is have a table row where the text wraps (This is easy)...
1
by: Dave Bennett | last post by:
I am hoping someone can help me because I am really beginning to hate IE. I am using the following code to generate a dynamic table. private void buildTable(ArrayList Products) { //Variables...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
4
by: Nathan Sokalski | last post by:
When editing an ASP Table, Visual Studio does not allow me to edit it in Design View. This makes it harder to add elements, because I must add every element either by using Design View to create...
1
by: 515331Ja_ck3410 | last post by:
asp:table was now nice with firefox alignement was not good maybe with the new versions the problem is gone someone knows?
5
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have the table like below: <asp:Table ID="tblControls" runat="server" HorizontalAlign="Center" Width="768px" Font-Names="Tahoma" Font-Size="Small" BorderStyle="Solid"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...
0
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...

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.