473,938 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Label within repeater losing text on post back

I have a repeater with some labels in it (code below). For whatever reason
the text for the label is not persisted in viewstate on the postback. Is
there a trick to get this to work? Is there something else I can do to get
the same visual effect (not using a datagrid :) )? This is annnooying!

<table>
<asp:repeater id="rptGunReadi ngsNew" runat="server">
<ItemTemplate >
<tr>
<td>
<asp:Label id="lblGunReadi ngID" runat="server" Visible="False"
EnableViewState ="True" > <%# DataBinder.Eval (Container.Data Item,
"GunReading ID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescript ion" runat="server"
CssClass="Large rMaroon" EnableViewState ="True"> <%#
DataBinder.Eval (Container.Data Item, "Descriptio n") %> </asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>

On the post back I am trying to do this ... and the text value is "".
foreach ( RepeaterItem item in rptGunReadingsN ew.Items ) {
object o1 = item.FindContro l( "lblGunReadingI D" );
object o2 = item.FindContro l( "lblDescription " );
}
Thanks,
Kevin
Nov 19 '05 #1
3 3943
Kevin,

Visible=False causes controls not to be sent to client. You can make
controls invisible with css rule display:none.

Eliyahu

"Kevin Cunningham" <no**@email.com > wrote in message
news:uQ******** ******@TK2MSFTN GP12.phx.gbl...
I have a repeater with some labels in it (code below). For whatever reason the text for the label is not persisted in viewstate on the postback. Is
there a trick to get this to work? Is there something else I can do to get the same visual effect (not using a datagrid :) )? This is annnooying!

<table>
<asp:repeater id="rptGunReadi ngsNew" runat="server">
<ItemTemplate >
<tr>
<td>
<asp:Label id="lblGunReadi ngID" runat="server" Visible="False"
EnableViewState ="True" > <%# DataBinder.Eval (Container.Data Item,
"GunReading ID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescript ion" runat="server"
CssClass="Large rMaroon" EnableViewState ="True"> <%#
DataBinder.Eval (Container.Data Item, "Descriptio n") %> </asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>

On the post back I am trying to do this ... and the text value is "".
foreach ( RepeaterItem item in rptGunReadingsN ew.Items ) {
object o1 = item.FindContro l( "lblGunReadingI D" );
object o2 = item.FindContro l( "lblDescription " );
}
Thanks,
Kevin

Nov 19 '05 #2
Gotcha, but still even when I turn it to visible it doesnt hold the .Text
value. Other controls work fine.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:Ot******** ******@TK2MSFTN GP14.phx.gbl...
Kevin,

Visible=False causes controls not to be sent to client. You can make
controls invisible with css rule display:none.

Eliyahu

"Kevin Cunningham" <no**@email.com > wrote in message
news:uQ******** ******@TK2MSFTN GP12.phx.gbl...
I have a repeater with some labels in it (code below). For whatever

reason
the text for the label is not persisted in viewstate on the postback. Is there a trick to get this to work? Is there something else I can do to

get
the same visual effect (not using a datagrid :) )? This is annnooying!

<table>
<asp:repeater id="rptGunReadi ngsNew" runat="server">
<ItemTemplate >
<tr>
<td>
<asp:Label id="lblGunReadi ngID" runat="server" Visible="False" EnableViewState ="True" > <%# DataBinder.Eval (Container.Data Item,
"GunReading ID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescript ion" runat="server"
CssClass="Large rMaroon" EnableViewState ="True"> <%#
DataBinder.Eval (Container.Data Item, "Descriptio n") %> </asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>

On the post back I am trying to do this ... and the text value is "".
foreach ( RepeaterItem item in rptGunReadingsN ew.Items ) {
object o1 = item.FindContro l( "lblGunReadingI D" );
object o2 = item.FindContro l( "lblDescription " );
}
Thanks,
Kevin


Nov 19 '05 #3
I thing it is because Label Text is not a part of the viewstate. You have to
rebind it every time.

Eliyahu

"Kevin C" <kc@noneya.co m> wrote in message
news:e0******** ******@TK2MSFTN GP10.phx.gbl...
Gotcha, but still even when I turn it to visible it doesnt hold the .Text
value. Other controls work fine.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:Ot******** ******@TK2MSFTN GP14.phx.gbl...
Kevin,

Visible=False causes controls not to be sent to client. You can make
controls invisible with css rule display:none.

Eliyahu

"Kevin Cunningham" <no**@email.com > wrote in message
news:uQ******** ******@TK2MSFTN GP12.phx.gbl...
I have a repeater with some labels in it (code below). For whatever

reason
the text for the label is not persisted in viewstate on the postback. Is there a trick to get this to work? Is there something else I can do to
get
the same visual effect (not using a datagrid :) )? This is
annnooying!
<table>
<asp:repeater id="rptGunReadi ngsNew" runat="server">
<ItemTemplate >
<tr>
<td>
<asp:Label id="lblGunReadi ngID" runat="server"

Visible="False" EnableViewState ="True" > <%# DataBinder.Eval (Container.Data Item,
"GunReading ID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescript ion" runat="server"
CssClass="Large rMaroon" EnableViewState ="True"> <%#
DataBinder.Eval (Container.Data Item, "Descriptio n") %> </asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>

On the post back I am trying to do this ... and the text value is "".
foreach ( RepeaterItem item in rptGunReadingsN ew.Items ) {
object o1 = item.FindContro l( "lblGunReadingI D" );
object o2 = item.FindContro l( "lblDescription " );
}
Thanks,
Kevin



Nov 19 '05 #4

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

Similar topics

2
3214
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how to do this is way complicated and assumes a familiarity with dot net that I don't have yet. I'll get it eventually but this is where I'll get it. Here's my code. First part is the user control and second is the code behind page Use control
0
2127
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
6
4583
by: Tom Kaminski [MVP] | last post by:
On my code behind page, how can I reference a Label control that's included in a Repeater? In other words, given: <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate> <table> <tr> <td><asp:Label ID="Label1"
1
2720
by: Matthew Curiale | last post by:
I have a ddl that is populated in my If Not IsPostBack block in the Page_load event. A repeater is also populated at this time, showing different domains for a website. The ddl contains different price plans that can be selected. My problem is that the user has a choice of being able to update information, or update and create a new domain. In doing either, if the user changes the index of the ddl, I lose all data in the ddl, and my...
1
9255
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the example WebForm1.aspx and WebForm1.aspx.cs code below: WebForm1.aspx =======================================================
4
1662
by: wrytat | last post by:
I've a big problem that I don't know how to solve for quite long. In one of my aspx file, I have a form that run at server. Within this form, there's a table. The first row is made up of some text boxes and a submit button. The remaining rows are made up of a data repeater, that display items that are previously inserted into the table. Its structure is just like a shopping cart table, whereby the first row you can add a new item, while the...
4
6349
by: Dabbler | last post by:
I'm trying to block out some text by setting Label width attribute which renders as a span tag so that all labels for textfields take up the same amount of space hence the textfields are all aligned but for some reason the width is being ignored in IE 6 even though it works in Firefox. Is there some bug associated with this and maybe the Doctype specification? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
2
3863
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub ShowData(obj As Object, ea As EventArgs) lblDate.Text = DateTime.Now.ToString("d") lblDate.DataBind() End Sub </script> <form runat="server"> <asp:Label ID="lblDate" OnDataBinding="ShowData" runat="server"/>
1
2568
by: supraracer | last post by:
Can anyone show me an example of a solution to the problem described in this thread? How do I rebind a label in a repeater on a postback? http://bytes.com/groups/net-asp/327013-label-within-repeater-losing-text-post-back (I don't seem to be able to post to that group or something). Thanks.
0
10134
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
9963
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11524
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11106
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...
1
11288
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10657
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
9857
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...
1
8218
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6295
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.