Accessing edit form textbox in RadTreeList

9 posts, 0 answers
  1. Maciej
    Maciej avatar
    14 posts
    Member since:
    Aug 2013

    Posted 20 Aug 2013 Link to this post

    Hi

    That's my first post on this forum :)

    I've got a problem with RadTreeList that I can't access edit form's textbox in OnItemDataBound event.

    .aspx looks like this:
    <EditFormSettings EditColumn-ButtonType="ImageButton"
                EditColumn-CancelImageUrl="~/Images/Actions/Cancel_16x16.png"
                EditColumn-InsertImageUrl="~/Images/Actions/Accept_16x16.png"
                EditColumn-UpdateImageUrl="~/Images/Actions/Accept_16x16.png"
                EditFormType="Template">
            <EditColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1" InsertImageUrl="~/Images/Actions/Accept_16x16.png" UpdateImageUrl="~/Images/Actions/Accept_16x16.png" CancelImageUrl="~/Images/Actions/Cancel_16x16.png"></EditColumn>
    <FormTemplate>
       <table>
        <tr><td></td><td>Dla jednostki</td><td>Jednostek podrzędnych</td></tr>
        <tr>
        <td>Limit wydatków łacznie</td>
        <td><telerik:RadNumericTextBox runat="server"  id="tbExpenditureLimit" DbValue='<%# Bind("ExpenditureLimit") %>'/></td>
        <td><asp:Label runat="server" ID="lblSUM_ExpenditureLimit" Text='<%# Eval("SUM_ExpenditureLimit") %>' /></td>
        </tr>

    And code behind

    protected void rtlOrgUnits_OnItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
    {
       if (e.Item is TreeListDataItem)
       {
       TreeListDataItem itm = e.Item as TreeListDataItem;
       bool isExpenditureLimitBlocked = initalization by some params;
       if (isExpenditureLimitBlocked)
       {
          if (itm is TreeListEditableItem && (itm as TreeListEditableItem).IsInEditMode)
          {
             TreeListEditableItem editItem = (TreeListEditableItem)itm;
     
              var tb = editItem.FindControl("tbExpenditureLimit") as RadTextBox;
              if (tb != null)
              {
                  tb.ReadOnly = true;
                  tb.BackColor = Color.FromArgb(1, 215, 215, 215);
               }
           }
    }

    And i get tb equal to null, so that's not what I'm expecting.
    How I can access this control ?

    I would be very very grateful for the answer,
    Greets Maciek :)
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2013 Link to this post

    Hi Maciej,

    Please try the following code snippet to access the RadNumericTextbox in ItemDataBound event.

    C#:
    protected void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
    {
        bool isExpenditureLimitBlocked = initalization by some params;
        if (isExpenditureLimitBlocked)
        {
            if (e.Item is TreeListEditableItem)
            {
                TreeListEditableItem editItem = (TreeListEditableItem)e.Item;
     
                var tb = editItem.FindControl("tbExpenditureLimit") as RadNumericTextBox;
                if (tb != null)
                {
                    tb.ReadOnly = true;
                    tb.BackColor = Color.FromArgb(1, 215, 215, 215);
                }
            }
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Maciej
    Maciej avatar
    14 posts
    Member since:
    Aug 2013

    Posted 21 Aug 2013 Link to this post

    Your code is almost exactly the same and unfortuanatelly not working.

    Anyway, thanks for the try :)
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2013 Link to this post

    Hi,

    Please try accessing edit from RadNumericTextbox using TreeListEditFormItem as shown below.

    C#:
    protected void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
    {
        bool isExpenditureLimitBlocked = initalization by some params;
        if (isExpenditureLimitBlocked)
        {
            if (e.Item is TreeListEditFormItem
            {
                TreeListEditFormItem editItem = (TreeListEditFormItem)e.Item;
      
                var tb = editItem.FindControl("tbExpenditureLimit") as RadNumericTextbox;
                if (tb != null)
                {
                    tb.ReadOnly = true;
                    tb.BackColor = Color.FromArgb(1, 215, 215, 215);
                }
            }
        }
    }

    Thanks,
    Shinu.
  6. Maciej
    Maciej avatar
    14 posts
    Member since:
    Aug 2013

    Posted 22 Aug 2013 Link to this post

    Hi

    This line
    if (e.Item is TreeListEditFormItem)

    Resharper tells me that "Expression is always false" and unfortunatelly he's right :(.

    Still, thanks for the try :)
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2013 Link to this post

    Hi,

    Unfortunately I couldn't relicate.Can you please provide your ASPX and C# code.

    Thanks,
    Shinu.
  8. Maciej
    Maciej avatar
    14 posts
    Member since:
    Aug 2013

    Posted 23 Aug 2013 Link to this post

    Hi Shinu,
    could you provide your e-mail ?
  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Aug 2013 Link to this post

    Hi Maciej,

    Yes. You can contact me via email -- shinu(at)softincubator(dot)com for any specific requirements / support.

    Best regards,
    Shinu.
  10. Mark
    Mark avatar
    2 posts
    Member since:
    Dec 2011

    Posted 14 Jul 2015 Link to this post

    Hi,

    What was the solution ? 

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017