ItemCreated fire twice

2 posts, 0 answers
  1. y
    y avatar
    1 posts
    Member since:
    Apr 2009

    Posted 17 Dec 2010 Link to this post

    I try to fill a combobox in the  RadListViewItem,but it do twice every time.

    protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
            {
               
                //if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
                {
                    RadComboBox combo = e.Item.FindControl("rcmbDept1") as RadComboBox;
                    if (combo != null)
                    {
                        fillChildExistDept(combo);
                    }
                }
            }





    <telerik:RadListView ID="RadListView1" runat="server" ItemPlaceholderID="ItemContainer"
                OnNeedDataSource="RadListView1_NeedDataSource" OnItemCreated="RadListView1_ItemCreated"
                OnItemDataBound="RadListView1_ItemDataBound"
                onprerender="RadListView1_PreRender">
                <LayoutTemplate>
                    <fieldset style="width: 100%;">
                        <legend>?????</legend>
                        <table cellpadding="0" cellspacing="0" style="width: 100%;">
                            <tr>
                                <td>
                                    <asp:Button ID="btnAddRecord" runat="server" CommandName="InitInsert" Visible="<%#Container.InsertItemPosition == RadListViewInsertItemPosition.None %>"
                                        Text="??????" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Panel ID="ItemContainer" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                        PageSize="3">
                                        <Fields>
                                            <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                            <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                            <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                        </Fields>
                                    </telerik:RadDataPager>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </LayoutTemplate>
                <ItemTemplate>
                    <fieldset style="float: left; width: 280px; height: 140px;">
                        <table cellpadding="2" cellspacing="0" style="height: 100%;">
                            <tr>
                                <td style="width: 20%;">
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <%# Eval("DeptName") %>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <%# Eval("CS")%>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <%# Eval("DS")%>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:ImageButton ID="Button1" runat="server" CommandName="Edit" ImageUrl="~/images/Edit1.gif" />&nbsp;
                                    <asp:ImageButton ID="Button2" runat="server" CommandName="Delete" CommandArgument='<%#Eval("ID") %>'
                                        ImageUrl="~/images/Delete1.gif" />
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </ItemTemplate>
                <EditItemTemplate>
                    <fieldset style="float: left; width: 280px; height: 140px;">
                        <table cellpadding="0" cellspacing="2" style="height: 100%">
                            <tr>
                                <td style="width: 20%;">
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <asp:TextBox ID="txtCS" runat="server" Text='<%# Bind("CS") %>' Width="75px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <asp:TextBox ID="txtDS" runat="server" Text='<%# Bind("DS") %>' Width="75px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:ImageButton ID="Button1" runat="server" CommandName="Update" Text="Update" ImageUrl="~/ListView/Examples/DefiningStructure/DeclarativeDefinition/Img/Update.gif" />
                                    <asp:ImageButton ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" ImageUrl="~/ListView/Examples/DefiningStructure/DeclarativeDefinition/Img/Cancel.gif" />
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <fieldset style="float: left; width: 280px; height: 140px;">
                        <table cellpadding="0" cellspacing="2" style="height: 100%">
                            <tr>
                                <td style="width: 20%;">
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <asp:TextBox ID="txtCS" runat="server" Width="75px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ????:
                                </td>
                                <td style="width: 80%; padding-left: 5px;">
                                    <asp:TextBox ID="txtDS" runat="server" Width="75px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:ImageButton ID="Button1" runat="server" CommandName="PerformInsert" Text="Insert"
                                        ImageUrl="~/images/Update.gif" />
                                    <asp:ImageButton ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" ImageUrl="~/images/Cancel.gif" />
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </InsertItemTemplate>
            </telerik:RadListView>
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 22 Dec 2010 Link to this post

    Hi,

    Do make sure that you are not rebinding the control at some point in the page life cycle. I am sending you a small sample that demonstrates the problem is not expected - I could not reproduct it.

    Hope it helps.

    All the best,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top