473,386 Members | 1,708 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,386 software developers and data experts.

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="rptGunReadingsNew" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label id="lblGunReadingID" runat="server" Visible="False"
EnableViewState="True" > <%# DataBinder.Eval(Container.DataItem,
"GunReadingID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescription" runat="server"
CssClass="LargerMaroon" EnableViewState="True"> <%#
DataBinder.Eval(Container.DataItem, "Description") %> </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 rptGunReadingsNew.Items ) {
object o1 = item.FindControl( "lblGunReadingID" );
object o2 = item.FindControl( "lblDescription" );
}
Thanks,
Kevin
Nov 19 '05 #1
3 3909
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**************@TK2MSFTNGP12.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="rptGunReadingsNew" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label id="lblGunReadingID" runat="server" Visible="False"
EnableViewState="True" > <%# DataBinder.Eval(Container.DataItem,
"GunReadingID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescription" runat="server"
CssClass="LargerMaroon" EnableViewState="True"> <%#
DataBinder.Eval(Container.DataItem, "Description") %> </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 rptGunReadingsNew.Items ) {
object o1 = item.FindControl( "lblGunReadingID" );
object o2 = item.FindControl( "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.com> wrote in message
news:Ot**************@TK2MSFTNGP14.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**************@TK2MSFTNGP12.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="rptGunReadingsNew" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label id="lblGunReadingID" runat="server" Visible="False" EnableViewState="True" > <%# DataBinder.Eval(Container.DataItem,
"GunReadingID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescription" runat="server"
CssClass="LargerMaroon" EnableViewState="True"> <%#
DataBinder.Eval(Container.DataItem, "Description") %> </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 rptGunReadingsNew.Items ) {
object o1 = item.FindControl( "lblGunReadingID" );
object o2 = item.FindControl( "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.com> wrote in message
news:e0**************@TK2MSFTNGP10.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.com> wrote in message
news:Ot**************@TK2MSFTNGP14.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**************@TK2MSFTNGP12.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="rptGunReadingsNew" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label id="lblGunReadingID" runat="server"

Visible="False" EnableViewState="True" > <%# DataBinder.Eval(Container.DataItem,
"GunReadingID") %> </asp:Label>
</td>
<td>
<asp:Label id="lblDescription" runat="server"
CssClass="LargerMaroon" EnableViewState="True"> <%#
DataBinder.Eval(Container.DataItem, "Description") %> </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 rptGunReadingsNew.Items ) {
object o1 = item.FindControl( "lblGunReadingID" );
object o2 = item.FindControl( "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
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...
0
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
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>...
1
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...
1
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...
4
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...
4
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...
2
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...
1
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? ...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
BarryA
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...
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
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...

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.