find control in ItemEditing

6 posts, 0 answers
  1. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 08 Nov 2014 Link to this post

    hi
    which find control for example, button, in RadListView1_ItemEditing

    i try below code,but give error.



      protected void RadListView1_ItemEditing(object sender, RadListViewCommandEventArgs e)
        {
    RadListViewEditableItem editedItem = (RadListViewEditableItem)e.ListViewItem;

     RadTextBox txtSubject =(RadTextBox)editedItem.FindControl("txtSubject");

    txtSubject .Text="hi";

    }
    please help me.
    thanks
  2. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 09 Nov 2014 Link to this post

    no any one, to help me?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 11 Nov 2014 Link to this post

    please Help!!!!!!!
  5. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 12 Nov 2014 Link to this post

    Hi Mohamad,

    Please try executing this logic on ItemDataBound event handler:
    http://www.telerik.com/help/aspnet-ajax/listview-accessing-controls.html

    You can also check the approach demonstrated in the following live sample for extracting the values to be updated:
    http://demos.telerik.com/aspnet-ajax/listview/examples/dataediting/manualediting/defaultcs.aspx

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 13 Nov 2014 Link to this post

    hi

    my normal view form have textbox with text(for example text box have this text > "Nice") ,  when i press the edit button, I have need, to add some text( for example add > "Re: ") to texbox.
    also need add  row number ,add to the textbox .
    in otherwise the texbox befor edite="nice"
    and after press edit="Re: nice"+ row number


    when i set value to propertice in RadListView1_PreRender or RadListView1_ItemCreated , give error

    for example when i set :
       protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
        {
        if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
            {
             
                RadEditor txtEditor = e.Item.FindControl("txtEditor") as RadEditor;

               txtEditor.Content += "Re: " + txtEditor.Content ;

            }
    }


    or
     protected void RadListView1_PreRender(object sender, EventArgs e)
        {

            RadEditor txtEditor = RadListView1.FindControl("txtEditor") as RadEditor;

            txtEditor.Content += "Re: " + txtEditor.Content;
    }

    give Error.

    please Help Me




  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 18 Nov 2014 Link to this post

    Hello Mohamad,

    In order to find controls within an item you must use the RadListViewDataItem object or the RadListViewEditableItem for the edit mode. You also need to handle the OnItemDataBound event, where the controls will be bound to a data and will hold the values that you need.

    For your convenience, following is a simple example demonstrating how to accomplish the result you need:
    <telerik:RadListView runat="server" ID="RadListView1" OnNeedDataSource="RadListView1_NeedDataSource"
        OnItemDataBound="RadListView1_ItemDataBound">
        <ItemTemplate>
            <asp:Label runat="server" ID="Label1" Text='<%# Eval("SomeField") %>'></asp:Label>
            <telerik:RadButton runat="server" ID="RadButton1" CommandName="Edit" Text="Edit"></telerik:RadButton>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTextBox runat="server" ID="RadTextBox1" Text='<%# Eval("SomeField") %>'></telerik:RadTextBox>
        </EditItemTemplate>
    </telerik:RadListView>

    And the code-behind:
    protected void RadListView1_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID", typeof(int));
        table.Columns.Add("SomeField", typeof(string));
        for (int i = 0; i < 1; i++)
        {
            table.Rows.Add(i, "Nice");
        }
     
        (sender as RadListView).DataSource = table;
    }
     
    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
    {
        if (e.Item is RadListViewEditableItem)
        {
            RadListViewEditableItem editItem = e.Item as RadListViewEditableItem;
            RadTextBox textBox = editItem.FindControl("RadTextBox1") as RadTextBox;
            textBox.Text = "Re: " + textBox.Text;
        }
    }


    Best Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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