update panel didn't close after updating

2 posts, 0 answers
  1. Ray
    Ray avatar
    8 posts
    Member since:
    Mar 2012

    Posted 30 Sep 2013 Link to this post

    Hi experts,

    I have two simple questions:

    1. I use treelist default update panel for updating/inserting, it works fine except that the panel didn't collapse after I click 'update' button, the data has been updated though, so I need to click 'cancel' button to hide the update panel after updating.

    2. I wonder how to define the textbox width in update panel, I didn't see anything obvious setting.

    My aspx code :
    <telerik:RadTreeList ID="RadTreeList1" runat="server"
                  OnUpdateCommand="RadTreeList1_UpdateCommand"
                  OnInsertCommand="RadTreeList1_InsertCommand"
                  OnDeleteCommand="RadTreeList1_DeleteCommand"
                  DataSourceID="SqlDataSource1"
                  AllowMultiItemSelection="True"
                  ParentDataKeyNames="parentId"
                  DataKeyNames="id" AutoGenerateColumns="False" Skin="Office2007"
                  AllowRecursiveDelete="True"
                  OnItemDrop="RadTreeList1_ItemDrop"
                  >
     
                   <Columns>
                        <telerik:TreeListDragDropColumn Visible="true" HeaderStyle-Width="20px" UniqueName="TreeListDragDropColumn"></telerik:TreeListDragDropColumn>
                         <telerik:TreeListTemplateColumn Visible="false" HeaderText="" UniqueName="ColumnUniqueName" DataField="Id">
                          <ItemTemplate>
                              <asp:Label ID="lblId" runat="server" Text='<%# Bind("Id") %>' Visible="false"></asp:Label>
                          </ItemTemplate>
                         </telerik:TreeListTemplateColumn>
     
                        <telerik:TreeListEditCommandColumn UniqueName="InsertCommandColumn" ButtonType="ImageButton" ShowEditButton="false" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center"></telerik:TreeListEditCommandColumn>
     
                        <telerik:TreeListButtonColumn CommandName="Edit" Text="Edit" UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center"></telerik:TreeListButtonColumn>
     
                        <telerik:TreeListButtonColumn UniqueName="DeleteCommandColumn" Text="Delete" CommandName="Delete" ButtonType="ImageButton" HeaderStyle-Width="30px"></telerik:TreeListButtonColumn>
     
                        <telerik:TreeListBoundColumn Visible="false" DataField="id" HeaderText="ID" ReadOnly="true" UniqueName="id" HeaderStyle-Width="60px" ForceExtractValue="Always"></telerik:TreeListBoundColumn>
     
                        <telerik:TreeListBoundColumn DataField="title" HeaderText="Title" UniqueName="title" HeaderStyle-Width="300px"></telerik:TreeListBoundColumn>
     
                        <telerik:TreeListBoundColumn DataField="link" HeaderText="Link" UniqueName="link" HeaderStyle-Width="300px"></telerik:TreeListBoundColumn>
     
                        <telerik:TreeListBoundColumn DataField="rank" HeaderText="Rank" UniqueName="rank" HeaderStyle-Width="60px"></telerik:TreeListBoundColumn>
     
                        <telerik:TreeListBoundColumn Visible="false" DataField="parentId" HeaderText="Parent ID" HeaderStyle-Width="80px" ReadOnly="true"></telerik:TreeListBoundColumn>
     
                   </Columns>
                   <ClientSettings AllowItemsDragDrop="true">
                                  <Selecting AllowItemSelection="True"></Selecting>
                                  <ClientEvents OnItemDropping="itemDropping" OnItemDragging="itemDragging"
                                  OnTreeListCreated="function(sender) { treeList1 = sender; }">
                                  </ClientEvents>
                             </ClientSettings>
              </telerik:RadTreeList>



    Many thanks for your help!
    Ray

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 03 Oct 2013 Link to this post

    Hi Ray,

    Please refer to  this help article regarding updating "RadTreeList". Also, please ensure that you have the following in your "UpdateCommand":
    protected void RadTreeList1_UpdateCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
    {
        //Canceling out the automatic datasource operation (needed if you use a datasource control)
        e.Canceled = true;
     
        ....
     
        //Closing the edit form and rebinding the treelist control
        RadTreeList1.EditIndexes.Clear();
        RadTreeList1.Rebind();
    }

    About your second question, you could handle the "ItemCreated" server-side event and change the "TreeListEditFormItem" TextBox control "Width" property as shown bellow:
    protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
    {
        if (e.Item is TreeListEditFormItem)
        {
            TreeListEditFormItem item = e.Item as TreeListEditFormItem;
            (item["title"].Controls[0] as TextBox).Width = Unit.Pixel(50);
        }
    }

    Hope that helps

     

    Regards,
    Konstantin Dikov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top