We have a list for which we wanted to bind a custom aspx page for editing the list item.
we have written the following sample console application to check it.
public class Program
{
public static void Main(string[] args)
{
using (SPSite site = new SPSite("http://HostName/"))
{
using (SPWeb web = site.RootWeb) // Tried with site.openWeb() also
{
SPList discList = web.Lists["ListWithCustomEditForms"];
SPFormCollection listForm = discList.Forms;
foreach (SPForm form in listForm)
{
Console.WriteLine(form.ServerRelativeUrl);
}
discList.DefaultEditFormUrl = @"~/layouts/CustomList_DynamicEditForm/EditListItemTest.aspx";
discList.Update();
Console.WriteLine("Done!!!!");
}
}
Console.ReadLine();
}
}
it's not accepting any path. Always it's throwing exception saying "Unable to find an SPForm matching URL ....". I have tried multiple options. but nothing is working.
Anything wrong with my code or is there any way to set the custom edit form for a list item?