Developer forum

Forum » CMS - Standard features » Forms for Datalists - List and edit records

Forms for Datalists - List and edit records

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I had a separate post about using forms for datalists  where I got some answers but not a very comprehensive description of how the setup should look like. And the current documentation is not very clear about setting up what I try to achieve.

long story short, I have a custom table that i want to display on the website and also have the ability to add and edit records.

I believe this should be acomplished with a combination of Datalist and Forms for datalists but it is a bit unclear how to connect the 2.

Displaying the records is pretty easy, I have done it a few times already.

Adding is also easy by using a dedicated Forms for Datalists and using the same table.

Edit functionality on the other hand, seems pretty unclear. I could not find a complete description on how to set it up. The template tag of EditLink returns 1 instead of a link and I am not sure how to use it.

Setting the default templates on the list surfaced the use of 2 URL parameters:FORM_ROW_ID and VIEW_ID

But when I created the link manually, I got this error:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.DataManagement.FormFrontend.GetFormRow(FormSetting form, String rowID, Int32 viewID)
   at Dynamicweb.DataManagement.FormFrontend.GetContent()
   at Dynamicweb.Frontend.Content.GetModuleOutput(Paragraph paragraph, PageView pageview)

Clearly, the module does not identify correctly the table or it does not have enough data.

My edit link looks like this: /add-new-skype-bet?FORM_ROW_ID=skypeBetsID&VIEW_ID=413

Is there any setting I need to make on the tabel? Or on the modules?

Can anybody describe a step-by-step setup of the above functionality?

Thank you,

Adrian 


Replies

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Adrian,

Haven't used it on DW9, but on a DW8 project I'm creating the link this way: FORM_ROW_ID=RecurringOrderReminderID%3d{RowID}&VIEW_ID={ViewID}.
RowID is the table record id.
ViewID is the datalist id.

Hope this helps!

BR, Mario

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Mario,

Seems close to the way I create it although I am a bit confused about the values that should be passed.

For {RowID} I am using the name of the field that is set as Primary Key on my table.
For {ViewID} I am using the value for that column 

You seem to pass the Column name and value in FORM_ROW_ID and in ViewID you send the Datalist ID? 

Thank you,
Adrian 

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Yes, that's what I'm doing.
FORM_ROW_ID={ColumnName}%3d{ColumnValue}. Not sure if works the same way on DW9 but it probably does wink

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Ok. Got it.

Now, where do you take the ViewID value from?

Is it from DMViewSettings table? ViewSettingsID?

Thanks,

Adrian

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Yes, or you can use the following code on DataList list template to get the value dynamically per paragraph: Pageview.CurrentParagraph.ModuleProperties.get_Value("ViewID")

BR, Mario

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Thank you Mario. I will give it a try.

Adrian

 

You must be logged in to post in the forum