By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Label within repeater losing text on post back

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.