API Questions on Kentico API.
Version 5.x > API > use "DataForm" control to create an edit page for a custome table View modes: 
User avatar
Member
Member
mj-y - 6/9/2013 4:35:49 AM
   
use "DataForm" control to create an edit page for a custome table
Hi
I used DataForm Control to create an edit form for one of my custome atbles. It shows the data correctley ... but after changing some items and hitting OK this error appears:
Form content which is intended to update does not exist.
what is the reason behind it?

.ascx page code:
<cms:DataForm ID="EditAdForm" runat="server" ClassName="Ad.Advertise" />

ascx.cs page code:
private string mAlternativeFormName = "Ad.Advertise.EditAdvertise";
public string AlternativeFormName
{
get
{
return mAlternativeFormName;
}
set
{
mAlternativeFormName = value;
EditAdForm.AlternativeFormFullName = value;
EditAdForm.VisibilityFormName = value;
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int adid =Convert.ToInt16( e.CommandArgument); EditAdForm.Info = AdInfoProvider.GetAdvertiseInfo(adid);
EditAdForm.AlternativeFormFullName = this.AlternativeFormName;
EditAdForm.VisibilityFormName = this.AlternativeFormName;
EditAdForm.AllowEditVisibility = true;
EditAdForm.IsLiveSite = true;
}

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/24/2013 6:19:11 AM
   
RE:use "DataForm" control to create an edit page for a custome table
Hi,

In your code I do not see any check for the DataForm mode. I believe that the default one is update mode. If you are inserting, you should set the mode to insert.

Also, when updating existing item, you should check its ItemID whether it exists or not.

Best regards,
Juraj Ondrus