asp:repeater events - how to postback

Posted by Kieran on Stack Overflow See other posts from Stack Overflow or by Kieran
Published on 2010-03-16T00:11:01Z Indexed on 2010/03/16 0:49 UTC
Read the original article Hit count: 392

Filed under:
|
|
|

Hello

I have an ASP:Repeater Which I would like to display a list of check boxes in. These check boxes are related to a list of user preferences and the users resulting answer. See Code Bellow.

I would like to add do one of the following if possible

Option 1: It would be great if I could use the Event in the Repeater:OnItemCommand(...) to fire if any of the items change. It would seem to me that this event will only fire if there is a Button | LinkButton | ImageButton item in the list. IE it will not fire if I put in a check box with AutopostBack="True"

Option 2: Is there a way I could attach a method to an Event of CheckBox:CheckChanged I would need to pass this method a parameter saying which question/answer combo to change.

Option 3: Its your answer if you know an easier way that would be awesome.

The Code:

<asp:Repeater ID="RPTprefs" runat="server" DataSourceID="getAnswers"    OnItemCommand="RPTprefs_ItemCommand">
      <ItemTemplate>
         <li><asp:CheckBox ID='questionID' runat="server" 
        Checked='<%# Eval("pr.up_is_selected") %>' 
        Text='<%# Eval("prp.prefs_question") %>' 
        AutoPostBack="true"
        OnCheckedChanged="CheckChanged"  /></li>
                </ItemTemplate>
               </asp:Repeater>

Thanks in advance

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#