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

Fire init insert command with empty datasource

3 Answers 113 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Lennart Burkels
Top achievements
Rank 1
Lennart Burkels asked on 13 Jan 2015, 02:50 PM
Hi,

Is it possible to fire the "init insert" command when there are no rows in the coupled datasource of the dataform object?

For now I created a button and in it's click event I put the following code:

Radform1.Items(0).FireCommandEvent("InitInsert", "")

But when the coupled datasource has no rows, it fails (because of the empty itemscollection).

Is there a workaround for inserting the "first row"?

Regards

3 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 15 Jan 2015, 12:47 AM
I also have the same problem. I got a button outside the raddataform to fire the InitInsert command and it doest work.
Does someone have any solutions?
Thanks a lot

protected void lbtAdd_Click(object sender, EventArgs e)
{
    int siteId = GetPageSiteID();
    //TODO - show form - insert new
    RadDataFormItem item = RadDataForm1.Items[0];
    item.FireCommandEvent("InitInsert", "");
 
}
0
Accepted
Viktor Tachev
Telerik team
answered on 16 Jan 2015, 08:46 AM
Hi,

I have built a sample project where the functionality is implemented. In addition there is a RadButton control placed outside of the RadDataForm that can be used to show the insert item.

The sample is attached to this post. Try using similar approach and you should be able to implement the functionality you are looking for.

Regards,
Viktor Tachev
Telerik
0
Lennart Burkels
Top achievements
Rank 1
answered on 16 Jan 2015, 10:23 AM
Thanks for your response. Put the button in the "emptydatatemplate" is a perfect workaround for my problem.

My first idea was to use a "create new" button outside the raddataform (in the toolbar for example) and fire the event. That's not possible with a empty list (I guess) perhaps in a later version.
Tags
DataForm
Asked by
Lennart Burkels
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Viktor Tachev
Telerik team
Lennart Burkels
Top achievements
Rank 1
Share this question
or