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

Find Control

3 Answers 221 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 19 Jan 2015, 10:38 AM
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

3 Answers, 1 is accepted

Sort by
0
Nicolas
Top achievements
Rank 1
answered on 19 Jan 2015, 11:02 AM
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
0
Eyup
Telerik team
answered on 22 Jan 2015, 09:13 AM
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
0
Nicolas
Top achievements
Rank 1
answered on 22 Jan 2015, 01:19 PM
Hi,

Yes it works !!!

Thanks
Tags
DataForm
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Nicolas
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or