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 3 3910
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
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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:
|
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>...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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?
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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: 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...
|
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,...
| |