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

find control not working

7 Answers 192 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 20 Jun 2012, 12:17 PM
Hi All,

I have an issue with tree list find control. when i put one Rad Text box inside the tree list i cant find the textbox reference in my code behind.. please help me for this issue..

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2012, 01:31 PM
Hi Prassin,

Try the following code snippet to access RadTextBox.

ASPX:
<telerik:RadTreeList ID="RadTreeList1" runat="server" DataSourceID="SqlDataSource1"  DataKeyNames="id" ...... ParentDataKeyNames="parent" OnItemDataBound="RadTreeList1_ItemDataBound"  ClientDataKeyNames="name" >
            <Columns>
                .......
                <telerik:TreeListTemplateColumn UniqueName="ColumnUniqueName">
                  <ItemTemplate>
                    <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox>
                  </ItemTemplate>
                </telerik:TreeListTemplateColumn >
            </Columns>
</telerik:RadTreeList>

C#:
protected void RadTreeList1_ItemDataBound(object sender, Telerik.Web.UI.TreeListItemDataBoundEventArgs e)
    {
        if (e.Item is TreeListDataItem)
        {
            TreeListDataItem item = e.Item as TreeListDataItem;
            RadTextBox txt = item["ColumnUniqueName"].FindControl("RadTextBox1") as RadTextBox;
        }
    }

Hope this helps.

Thanks,
Shinu.
0
Prassin
Top achievements
Rank 1
answered on 27 Jun 2012, 09:30 AM
Hi Shinu..

thanks for your help...  in data bound its working well.. but i need this functionality inside the "OnEditCommand"  event in tree list..
if you know about this then please share with me..

Regards,

Prassin
0
Shinu
Top achievements
Rank 2
answered on 27 Jun 2012, 10:52 AM
Hi Prassin,

Here is the sample code which works as expected at my end.

C#:
protected void RadTreeList_EditCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
    {
        TreeListDataItem item = e.Item as TreeListDataItem;
        RadTextBox txt = item["ColumnUniqueName"].FindControl("RadTextBox1") as RadTextBox;
    }

Hope this helps.

Thanks,
Shinu.
0
Prassin
Top achievements
Rank 1
answered on 27 Jun 2012, 11:43 AM
Hi Shinu..

am sorry .. its not working.. 

protected void RadTreeList1_EditCommand(object sender, TreeListCommandEventArgs e)
{
	TreeListDataItem item = e.Item as TreeListDataItem;
	RadTextBox txt = item("SubCatCode").FindControl("txtBoxcode") as RadTextBox;
	txt.Enabled = false;
}


  <telerik:RadTextBox ID="txtBoxcode" Text= '<%# Bind("SubCatCode") %>' runat="server" Height="8Pt"
  Style="text-transform: uppercase" MaxLength="4">
    </telerik:RadTextBox>

can you please check this code and confirm..

Regards,

Prassin
0
Shinu
Top achievements
Rank 2
answered on 28 Jun 2012, 05:13 AM
Hello Prassin,

Unfortunately I cannot replicate the issue at my end. Here I am pasting the full code that I tried which worked as expected.
aspx:
<telerik:RadTreeList ID="RadTreeList1" runat="server"  DataSourceID="SqlDataSource1" ClientSettings-AllowItemsDragDrop="true" DataKeyNames="id" ParentDataKeyNames="parent" AutoGenerateColumns="false" oneditcommand="RadTreeList1_EditCommand" >
  <Columns>
     <telerik:TreeListEditCommandColumn></telerik:TreeListEditCommandColumn>
      . . .
     <telerik:TreeListTemplateColumn >
      <ItemTemplate>
         <telerik:RadTextBox ID="txtBoxcode" Text= '<%# Bind("SubCatCode") %>' runat="server" Height="8Pt" Style="text-transform: uppercase" MaxLength="4"></telerik:RadTextBox>
      </ItemTemplate>
    </telerik:TreeListTemplateColumn>
 </Columns>
</telerik:RadTreeList>
C#:
protected void RadTreeList1_EditCommand(object sender, TreeListCommandEventArgs e)
{
        TreeListDataItem item = e.Item as TreeListDataItem;
        RadTextBox txt = item.FindControl("txtBoxcode") as RadTextBox;
 }

Thanks,
Shinu.
0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 06:36 AM
Hi Shinu..

Thanks for your help..
but am sorry say this .. this code is not working in my side.. its give an reference error " Object reference not set to an instance of an object. "

the error occur at  the time of disabling the textbox control... my need is disable or readonly  one text text box while click edit...


Regards,

Prassin

0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 10:18 AM
Hi Shinu,,

I fixed the issue .... thanks soo much for your help..

Regards,

Prassin
Tags
TreeList
Asked by
Prassin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Prassin
Top achievements
Rank 1
Share this question
or