Embedded Checkbox event not firing

2 posts, 1 answers
  1. Tonyz289
    Tonyz289  avatar
    50 posts
    Member since:
    Jun 2011

    Posted 25 Jan 2012 Link to this post

    I have a listview of the contains a image and  check box. I cannot get the OnCheckedChanged event to fire.
    The Listview output is attached and the code that creates is below:
    <telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" ItemPlaceholderID="PlaceHolder1"
        Skin="listview_2" EnableEmbeddedSkins="false" OnItemCreated="RadListView1_ItemCreated"
        DataKeyNames="id,filenameextension,typeAbbr,title" OnNeedDataSource="RadListView1_NeedDataSource">
        <LayoutTemplate>
            <div class="RadListView RadListViewFloated RadListView_Windows7">
                <telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="25" PagedControlID="RadListView1"
                    BorderWidth="0" OnFieldCreated="RadDataPager1_FieldCreated" CssClass="dataPagerClass">
                    <Fields>
                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="5" />
                        <telerik:RadDataPagerButtonField FieldType="NextLast" />
                        <telerik:RadDataPagerPageSizeField PageSizeText="Page size: " />
                        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                            TextBoxWidth="15" />
                        <telerik:RadDataPagerTemplatePageField>
                            <PagerTemplate>
                                <b>Total Number of Assets Found:
                                    <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                </b>
                            </PagerTemplate>
                        </telerik:RadDataPagerTemplatePageField>
                    </Fields>
                </telerik:RadDataPager>
                <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <div style="float: left; width: 162px; height: 200px; background-color: White;">
                <asp:Panel ID="myThumb" runat="server" CssClass="myClass" Style="border: 0; white-space: normal;
                    padding: 5px 2px 25px 2px; background-color: #F0F8FF; text-align: center;
                    width: 156px">
                    <asp:HyperLink ID="HyperLink1" runat="server" >
                        <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AutoAdjustImageControlSize="False"
                            CssClass="myClass" ImageUrl='<%# Eval("thumbUrl") %>' AlternateText="Click to view preview"
                            ToolTip="Click to view preview" Width="150px" Height="150px" />
                    </asp:HyperLink><br />
                    <asp:CheckBox ID="ChkImage" runat="server" Style="float: left; padding-top: 5px" OnCheckedChanged="ChkImage_CheckedChanged" /><small><asp:HyperLink
                        ID="lnkAsset1" runat="server" Visible="false" Style="float: left; padding-top: 5px">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset2" runat="server" Style="float: left;">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset3" runat="server" Style="float: left;
                        padding-left: 20px"></asp:HyperLink></small><br />
                   <asp:HiddenField ID="hiddenAssetId" Value='<%# Eval("id") %>' runat="server" />
                </asp:Panel>
            </div>
        </ItemTemplate>
        <EmptyDataTemplate>
            No Assets Found
        </EmptyDataTemplate>
    </telerik:RadListView>

    The code to fire on the event is here;
    protected void ChkImage_CheckedChanged (object sender, EventArgs e)
    {
        CheckBox ChkImage = RadListView1.FindControl ("ChkImage") as CheckBox;
        Boolean chk = ChkImage.Checked;
    }
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Jan 2012 Link to this post

    Hello,

    Try setting AutoPostBack property of CheckBox as true.

    Thanks,
    Princy.
Back to Top