DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 12 Aug 2007 13:48:15 +0100,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Mick Walker
          2    Teemu Keiski
                 3    Mick Walker
                 4    Teemu Keiski
                 5    Mick Walker


Repeater Issue   
I am using a repeater to display contacts to the user.

Here is my repeater:

<asp:Repeater ID="RepContacts" runat="server">

     <HeaderTemplate><table cellpadding="5" cellspacing="2">
                     <tr>
                         <td><b>Contact Name</b></td> 

                         <td></td>
                         <td><b>Invite</b></td>
                     </tr>
                 </HeaderTemplate>
                 <ItemTemplate>
                         <tr class="RowStyle">
                             <td align="left" valign="top">
                                 <asp:label width="300px" ID="lblName" 
Text='<%# left(Eval("Name"), 280) %>' runat="server"></asp:label>
                                 <asp:TextBox ID="txtID" runat="server" 
Visible="false" Text='<%#Eval("ID") %>' />
                                 <asp:TextBox ID="txtEmail" 
runat="server" Visible="false" Text='<%#Eval("Email") %>' /></td>
                             <td> </td>
                             <td align="left" valign="top">
                                 <asp:CheckBox ID="chkInvite" 
runat="server" />
                             </td>
                         </tr>
                </ItemTemplate>
                     <FooterTemplate></table></FooterTemplate>
      </asp:Repeater>

I set the data source property via my code behind and bind it to the 
repeater, and all works fine.

When i come to process the user options however, I have an issue. Here 
is my code:

'loop through the repeater
         For Each Item As RepeaterItem In RepContacts.Items
             Dim chkInvite As New CheckBox
             ChkInvite = CType(Item.FindControl("chkInvite"), CheckBox)
             Dim txtEmail As New TextBox
             txtEmail = CType(Item.FindControl("txtEmail"), TextBox)
             Dim txtID As New TextBox
             txtID = CType(Item.FindControl("txtID"), TextBox)
             If chkInvite.Checked = True Then
                 'Do Stuff ' Never gets called for some reason???
             End If

         Next

When I debug, not matter what the value of the checkbox on the repeater, 
the code picks it up as Checked = False. It gets the values of the text 
boxes fine, but I am really at a loss as to why this is happening.


Anyone care to lend a hand?

Regards
Mick
Date:Sun, 12 Aug 2007 13:48:15 +0100   Author:  

Re: Repeater Issue   
Hi,

and in Page_Load you do databind inside If Not Page.IsPostBack check? You 
shouldn't databind on every request, that's the point.

-- 
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Mick Walker"  wrote in message 
news:5i8duiF3nnb21U1@mid.individual.net...

>I am using a repeater to display contacts to the user.
>
> Here is my repeater:
>
> <asp:Repeater ID="RepContacts" runat="server">
>
>     <HeaderTemplate><table cellpadding="5" cellspacing="2">
>                     <tr>
>                         <td><b>Contact Name</b></td>
>                         <td></td>
>                         <td><b>Invite</b></td>
>                     </tr>
>                 </HeaderTemplate>
>                 <ItemTemplate>
>                         <tr class="RowStyle">
>                             <td align="left" valign="top">
>                                 <asp:label width="300px" ID="lblName" 
> Text='<%# left(Eval("Name"), 280) %>' runat="server"></asp:label>
>                                 <asp:TextBox ID="txtID" runat="server" 
> Visible="false" Text='<%#Eval("ID") %>' />
>                                 <asp:TextBox ID="txtEmail" runat="server" 
> Visible="false" Text='<%#Eval("Email") %>' /></td>
>                             <td> </td>
>                             <td align="left" valign="top">
>                                 <asp:CheckBox ID="chkInvite" 
> runat="server" />
>                             </td>
>                         </tr>
>                </ItemTemplate>
>                     <FooterTemplate></table></FooterTemplate>
>      </asp:Repeater>
>
> I set the data source property via my code behind and bind it to the 
> repeater, and all works fine.
>
> When i come to process the user options however, I have an issue. Here is 
> my code:
>
> 'loop through the repeater
>         For Each Item As RepeaterItem In RepContacts.Items
>             Dim chkInvite As New CheckBox
>             ChkInvite = CType(Item.FindControl("chkInvite"), CheckBox)
>             Dim txtEmail As New TextBox
>             txtEmail = CType(Item.FindControl("txtEmail"), TextBox)
>             Dim txtID As New TextBox
>             txtID = CType(Item.FindControl("txtID"), TextBox)
>             If chkInvite.Checked = True Then
>                 'Do Stuff ' Never gets called for some reason???
>             End If
>
>         Next
>
> When I debug, not matter what the value of the checkbox on the repeater, 
> the code picks it up as Checked = False. It gets the values of the text 
> boxes fine, but I am really at a loss as to why this is happening.
>
>
> Anyone care to lend a hand?
>
> Regards
> Mick 
Date:Sun, 12 Aug 2007 16:19:51 +0300   Author:  

Re: Repeater Issue   
Teemu Keiski wrote:

> Hi,
> 
> and in Page_Load you do databind inside If Not Page.IsPostBack check? You 
> shouldn't databind on every request, that's the point.
> 

No the data is only being bound in the button event.
Date:Sun, 12 Aug 2007 18:25:37 +0100   Author:  

Re: Repeater Issue   
Normally only accidental rebinding causes the state of CheckBoxes etc to 
appear as if selections has no impact (basically because databinding clears 
the changes before postback events). So post some code that demonstrates 
what happens on your page.

-- 
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Mick Walker"  wrote in message 
news:5i8u6lF3nkj87U1@mid.individual.net...

> Teemu Keiski wrote:
>> Hi,
>>
>> and in Page_Load you do databind inside If Not Page.IsPostBack check? You 
>> shouldn't databind on every request, that's the point.
>>
> No the data is only being bound in the button event. 
Date:Sun, 12 Aug 2007 21:50:07 +0300   Author:  

Re: Repeater Issue   
Teemu Keiski wrote:

> Normally only accidental rebinding causes the state of CheckBoxes etc to 
> appear as if selections has no impact (basically because databinding clears 
> the changes before postback events). So post some code that demonstrates 
> what happens on your page.
> 

I figured out my problem.

I was using a 3rd party AJAX control on the page, and the AutoPostback 
event of the checkbox was set to true. Stupid error, but thanks for your 
help.
Date:Mon, 13 Aug 2007 10:20:42 +0100   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us