Developer forum

Forum » CMS - Standard features » Update Row using Forms for DataLists

Update Row using Forms for DataLists

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I know this seems like an ancient topic but, believe it or not, I am still using DataLists and Forms for DataLists when I want to avoid having to write custom code for simple changes.

In this case, though, I am stuck.

I have created a DataList and a corresponding form for Editing.

I have set the DataList to use default templates and I got to an editing link of this form:

Default.aspx?ID={EDIT_PAGE_ID}&FORM_ROW_ID=ID%3d{Row.Value}&VIEW_ID={VIEW_ID}

All good and nice so far, although I have struggled a bit to understand what each parameter means.

The problem now is that the Form page does not display any value that is stored on the corresponding Row.

I have used TemplateTags, just to be sure I won't be making any suppositions.

I get the list of fields but the Value property is empty, regardless of what I have stored on the row. My guess is the row content is not retrieved correctly.

Is there any setting that may have something to do with this approach? I could swear I have seen the Editing work on other projects.

The Solution in my case is  9.13.13.

Thank you,

Adrian


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Anybody?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

I have not been in this module for 10 years minimum!

Looking at the code - the RowID is the value of the primary key column in the table if there is only one primary key column.

If there are 2 or more primary key columns, the RowID will be col1=val1&col2=val2 - i.e. if you publish EcomProducts that has 3 key columns, the rowid would have a value like "ProductID=prod1&LanguageID=lang1&VariantID=VO1"

When you render the form there is a tag "Form.Hidden" that will contain the rowid and the viewid so you can see the data.

To get the field values, you need to either render Form.Fields loop which will give you the value in Field.Value

If you do not use the loop, the value will be in Form.Fields.{ColumnName}.Value tag outside the loop.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you for the detailed answer.

In this case, I believe that my code is correct but I still don't get values for the fields. I have used TemplateTags just to be sure I am not making wrong assumptions.

The list of fields is rendered but without values. And I have checked what would happen if I provide wrong/invalid values for either the column name or the value and if something is wrong, I get a C# error. This means that I provide the right column name and value.

And I only have one key column.

Could there be any other setting in the FormsForEditor module? or in the setup of the Form?

Thank you,
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Since you have poked around the DataLists/Forms for Datalists module, can you also have a look if it should support Delete functionality?

Thank you,
Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

It does not. This module is a gigantic security issue already, and adding delete would make it worse.

I cannot figure out why you do not get the value. It could be that the rowid you supply does not hit an existing record because your format is wrong. So maybe I need to see some dumps.

Also remember that this thing is from back when there were only html templates.

Today you can just do Database.CreateDatareader and read the data from that. Simple CRUD is probably easier to do directly in the template - you can still use the backend for managing.

BR Nicolai

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Here is what I have

Database data:

 

View Settings:

 

Link generated by the default templates:

http://tingstad.staging.dynamicweb-cms.com/min-konto/to-boks/edit-toboks?FORM_ROW_ID=Id%3D8&VIEW_ID=6

Result (using old HTML templates)

You have the link above if you want to have a look in how it's configured.

I understand the limitations of the DataLists, I will figure out a way to handle the Delete part. If Edit works, I can use a property to soft delete the line instead of deleting it permanently from the table.

Than you,
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I believe I have figured out the issue.

If I remove all conditionals from the DataList (I was filtering by a QueryStringParameter) the values show up on the edit form.

I guess I need to figure out a way to keep conditionals and editing at the same time or create 2 separate lists. I am not sure why the definition of the DataList overlaps with the editing capabilities of the Forms for Datalists but probably that's a topic for another time.

Thank you,
Adrian

 

You must be logged in to post in the forum