Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Repeater Issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mick Walker - 12 Aug 2007 13:48 GMT
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>&nbsp;</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
Teemu Keiski - 12 Aug 2007 14:19 GMT
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.

Signature

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

>I am using a repeater to display contacts to the user.
>
[quoted text clipped - 56 lines]
> Regards
> Mick
Mick Walker - 12 Aug 2007 18:25 GMT
> 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.
Teemu Keiski - 12 Aug 2007 19:50 GMT
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.

Signature

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

>> 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.
Mick Walker - 13 Aug 2007 10:20 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.