This is a migrated thread and some comments may be shown as answers.

Accessing edit form textbox in RadTreeList

8 Answers 61 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Maciej
Top achievements
Rank 1
Maciej asked on 20 Aug 2013, 01:28 PM
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 :)

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 21 Aug 2013, 04:49 AM
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.
0
Maciej
Top achievements
Rank 1
answered on 21 Aug 2013, 08:14 AM
Your code is almost exactly the same and unfortuanatelly not working.

Anyway, thanks for the try :)
0
Shinu
Top achievements
Rank 1
answered on 22 Aug 2013, 04:42 AM
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.
0
Maciej
Top achievements
Rank 1
answered on 22 Aug 2013, 07:13 AM
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 :)
0
Shinu
Top achievements
Rank 1
answered on 22 Aug 2013, 08:00 AM
Hi,

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

Thanks,
Shinu.
0
Maciej
Top achievements
Rank 1
answered on 23 Aug 2013, 10:19 AM
Hi Shinu,
could you provide your e-mail ?
0
Shinu
Top achievements
Rank 1
answered on 26 Aug 2013, 07:53 AM
Hi Maciej,

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

Best regards,
Shinu.
0
Mark
Top achievements
Rank 1
answered on 14 Jul 2015, 07:52 PM

Hi,

What was the solution ? 

 

Tags
TreeList
Asked by
Maciej
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Maciej
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or