Repeater Issue

M

Mick Walker

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
 
T

Teemu Keiski

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.
 
M

Mick Walker

Teemu said:
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.
 
T

Teemu Keiski

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.
 
M

Mick Walker

Teemu said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,736
Members
45,709
Latest member
DRISenaida

Latest Threads

Top