0

I am trying to use checkboxes to select the items in a Listview. I have added a checkbox control in the , and they are displayed properly.

The problem is that Checked property never changes when I click on them. Why does this happen? And is there a workaround?

Here is the code:

<asp:ListView ID="ListView1" runat="server" 
    onitemcommand="ListView1_ItemCommand" 
    onitemdatabound="ListView1_ItemDataBound">
    <LayoutTemplate>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
    </LayoutTemplate>
    <ItemTemplate>
        <asp:CheckBox ID="CheckBoxSelect" runat="server" OnCheckedChanged="CheckBoxSelect_checkchanged"/>            
        <asp:LinkButton ID="LinkButtonOpen" CommandArgument='<%#Eval("MessageID") %>' runat="server">            
            &nbsp; &nbsp; &nbsp;
            <asp:Label ID="Label1" Text="[]" runat="server"/>
            &nbsp; &nbsp; &nbsp;
            <%#Eval("FirstName" )%>&nbsp;<%#Eval("LastName")%>
            &nbsp; &nbsp; &nbsp;
            <%#Eval("Subject") %>
            &nbsp; &nbsp; &nbsp;
            <%#Eval("Timestamp") %>
            <asp:HiddenField runat="server" ID="ReadStatus" Value='<%#Eval("IsRead") %>' />
        </asp:LinkButton>
    </ItemTemplate>
</asp:ListView>
1
  • at least post the screenshot of your UI Commented Apr 30, 2010 at 8:36

2 Answers 2

1

I think you are missing the AutoPostBack="true"

<asp:CheckBox ID="CheckBoxSelect" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBoxSelect_checkchanged"/>       
Sign up to request clarification or add additional context in comments.

Comments

1

The problem was that I was binding the ListView during page load. When that happened, the checkboxes would get cleared, and I got the Checked property as False in all subsequent functions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.