find control not working

8 posts, 0 answers
  1. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2012 Link to this post

    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..
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jun 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 27 Jun 2012 Link to this post

    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
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jun 2012 Link to this post

    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.
  6. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 27 Jun 2012 Link to this post

    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
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Jun 2012 Link to this post

    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.
  8. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 28 Jun 2012 Link to this post

    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

  9. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 28 Jun 2012 Link to this post

    Hi Shinu,,

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

    Regards,

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