Find Control

4 posts, 0 answers
  1. Nicolas
    Nicolas avatar
    3 posts
    Member since:
    Jan 2015

    Posted 19 Jan 2015 Link to this post

    Hi,

    I've a question regarding RadDataForm.
    In my dataForm, I've a textBox (ie. "_txtOpenDate").
    When I click on Insert button, I want to change the date with the Today date.

    How can I do this ? I tried the FindControl("txtOpenDate") method but each time I 've a null reference (every method such as ItemInserting, ItemCommand ...)

    Thanks
  2. Nicolas
    Nicolas avatar
    3 posts
    Member since:
    Jan 2015

    Posted 19 Jan 2015 in reply to Nicolas Link to this post

    Hi,

    To be more clear, I want to do this (works well with a standard Formview, but I want to do with a RadDataForm)

    protected void FormView1_DataBound(object sender, EventArgs e)
    {
    if (FormView1.CurrentMode==FormViewMode.Insert)
    {
    var _txt = (TextBox)FormView1.FindControl("TicketnumberTextBox");
    _txt.Text = "Ticket number 1259";
    }
    }
    Thanks
  3. Eyup
    Admin
    Eyup avatar
    3225 posts

    Posted 22 Jan 2015 Link to this post

    Hello Nicolas,

    Currently, you can use the ItemCreated event handler instead:
    protected void RadDataForm1_ItemCreated(object sender, RadDataFormItemEventArgs e)
    {
        if (e.Item is IRadDataFormInsertItem)
        {
            RadDataFormEditableItem item = e.Item as RadDataFormEditableItem;
            TextBox textBox = item.FindControl("CompanyNameTextBox") as TextBox;
            textBox.Text = "Success";
        }
    }

    Hope this helps. Please give it a try and let me know about the result.

    Regards,
    Eyup
    Telerik
  4. Nicolas
    Nicolas avatar
    3 posts
    Member since:
    Jan 2015

    Posted 22 Jan 2015 in reply to Eyup Link to this post

    Hi,

    Yes it works !!!

    Thanks
Back to Top