Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Label within repeater losing text on post back

Reply
Thread Tools

Label within repeater losing text on post back

 
 
Kevin Cunningham
Guest
Posts: n/a
 
      01-20-2005
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


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-20-2005
Kevin,

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

Eliyahu

"Kevin Cunningham" <(E-Mail Removed)> wrote in message
news:uQUcXbq$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Kevin C
Guest
Posts: n/a
 
      01-20-2005
Gotcha, but still even when I turn it to visible it doesnt hold the .Text
value. Other controls work fine.

"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:OtxiGKt$(E-Mail Removed)...
> Kevin,
>
> Visible=False causes controls not to be sent to client. You can make
> controls invisible with css rule display:none.
>
> Eliyahu
>
> "Kevin Cunningham" <(E-Mail Removed)> wrote in message
> news:uQUcXbq$(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-20-2005
I thing it is because Label Text is not a part of the viewstate. You have to
rebind it every time.

Eliyahu

"Kevin C" <(E-Mail Removed)> wrote in message
news:e0dFXvv$(E-Mail Removed)...
> Gotcha, but still even when I turn it to visible it doesnt hold the .Text
> value. Other controls work fine.
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:OtxiGKt$(E-Mail Removed)...
> > Kevin,
> >
> > Visible=False causes controls not to be sent to client. You can make
> > controls invisible with css rule display:none.
> >
> > Eliyahu
> >
> > "Kevin Cunningham" <(E-Mail Removed)> wrote in message
> > news:uQUcXbq$(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Losing Drives - Finding Drives - Losing Drives mel@no.spam.com Computer Support 2 09-21-2007 10:16 PM
How does a dynamic control load post back data across post back?? =?Utf-8?B?Z29yaWxsYQ==?= ASP .Net 1 05-25-2007 05:02 AM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
ASP.NET 2.0 - Losing controls added in post back Michael Lang ASP .Net 12 12-29-2006 12:34 AM
textbox in user control losing values during post back =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 2 08-23-2006 03:14 PM



Advertisments