I'm currently working on a project to generate forms from the Umbraco (V.10) backend (I know that there is Umbraco Forms, but this is not an option).
I have a parent Node called "Formular" this generates the <form> tag. The parent can have various children like "Input Form Field", "Date Time Form Field" etc. These create an <input> field.
Document types
What I want to do is to generate a database table from all child nodes of the "Formular" node. The database attribute names should be the node ID.
A child node has a radio list with types like "text", "textarea", "number" etc. to set the <input type="">. If the type is getting changed or a node is deleted, a new table should be generated with the new child nodes. It would be an option to update the table if a new node was added and to set the previous entries to null in this column.
Example table
I thought that I could create a custom section where all child nodes are shown with their datatype and a button that is activated if any changes were made in the nodes. If the button is getting clicked, it generates the new table (maybe the table name could be set in the section too).
If this helps somehow, I can send my form with ajax this is how it looks:
Ajax POST
I tried to create a table with the id and data types which I get from my ajax post, but I realized, that it is dumb to always check if the id and datatype are the same in the table and to create a new one if this is false. So I thought about creating the table directly from the Umbraco nodes.
My problem is, that I don't know how to generate the table if I don't have a model with attributes like "public int ...". And since there is no way to generate these attributes with a loop i have no idea how to create the table.
Any thoughts on this problem?
Thanks
I have been working on that for quite a long time, but I could figure out a better way than creating the database table from the content nodes.
I just generated a table "FormSubmission" that saves a nodeId each time the form has been submitted. Then I created a second table named "FormContext". This one is related to the ID of the submission, and each input field gets saved as one table entry in the "FormContext" table with the submission ID as foreign key.
UML
This way I'm able to select all entries of a specific form and I can select all content a person has entered into the form.
Since I have all types an input field can have in the table, I don't have to update the table when the form changes or one form gets deleted.
I then created the tables like the umbraco documentation tells and just had to insert the data into the tables.
Umbraco creating a custom database table
I know this is not the most beautiful way but it works.
Related
I currently have a DataSet that has several tables in it for a C# Windows app. I have one parent table and all of the other tables in this set are child tables that have a relation to the ID column in the parent.
I just recently added a new table and made the necessary relation to the parent table through the wizard and designer, not coding. However, when I go to my form and try to change the DataMember on the property screen of the BindingSource, it doesn't find the relation that I just created in the drop down menu. I try to manually input the name of the relation and I receive the error message listed in the title.
I've never had this issue before when I have added child tables to the DataSet and then changed the DataMembers for them so I'm not really sure where to go from here in order to resolve this issue. Any assistance would be awesome.
Let me know if you need more information.
Edit: I should also add that it seems to only be happening with this one DataSet. I tried adding the exact same table to a different DataSet I had and everything worked without an issue.
I have a table called TableExplorer which contains other table's names and their respective column names.
For example: table Customer may have 5 columns but in TableExplorer I may mention only 2 column names out of 5.
User send me the table name in query string, my job is to find that table name whether it is present or not in TableExplorer which I mentioned initially. If the user mentioned table is present then I should bind that table to a gridview and that gridview should have functionality like edit, delete, update. Finally any operation like edit, delete or update made by user should reflect in the respective table as mentioned by the user.
Database used : SQL Server 2008 R2
Programming language : C#, ASP.NET
Thanks in advance for helping.
Are you using WebForms? I'm far from being a WebForms expert but this is what I'd do:
You create different pages with GridView control, one for each table that you might want to bind, eg. Customer table. You create the CRUD operation for this GridView, Insert, Update, Delete. You create parameters for all the columns that the user might need, some of them could be invisible.
The user goes to his selection page, he choses a table and a list of columns and press Submit his request. Whenever you receive the query string you do 2 things:
Identify what table your user is asking and load the right page, if available. Maybe you can load only the specific GridView control in a specific using Ajax. Or maybe you can simple load another page.
Get the list of columns that the user wants to see in his grid from the querystring. Before showing the grid to him you keep these columns visible and hide/remove from the gridview every other column. You must pass this parameter to your insert/update methods as well.
I think this is a good solution to start, assuming you don't have a list of hundreds of tables, I wouldn't try to create something completely dynamic.
I have two tables that one table is parent and the other is child.
First,in form load, I wanna add a row to Parent, after that use Parent ID in child Table.
Of course all of those are temporary, till user confirm and save finally.
But through my code, I received this error:
ForeignKeyConstraint
FK_Table385_ParentTable_Table380_ChildTable
requires the child key values (3) to
exist in the parent table.
I know what this error means, and I can update Parent Table after that add rows to my child Table. But I can not do that. because all of those works are temporary till user confirm operation.
So what can I do?
If you configure your Typed datasets correctly this is handled automatically.
I don't recall all details but it requires the use of AutoIncrement on the PK and Cascading updates in the Relation.
You ought to see (debugger) that the new records get temporary negative values.
So if that (3) is the key value, something ain't right.
Use Datasets: insert data offline in your application and commit to database when user confirms.
To put simple:
I have a database with two tables...
I use a datamodel to connect to the database
I create two classes which store my methods and properties for the two tables
I create one form for gathering information on table 1 and click next (hyperlinks to another page)
I pass the table 1's ID through and then I have a problem. The data submitted for table 2 is inter-changeable meaning it will vary how much data will be submitted for table 2 based on the id of table
My question is, how can I create a dynamic webform which will allow users to click an add button and it adds another textbox or a copy of the one that is currently on the page? I then want to put them into a list and then send them off to the table 1 database using an insert method from the datamodel.
To make it simple for point [5] say you have a book, name, author, publisher etc. That could be an example for table 1. But for table 2 I then want the user to put each page number into seperate textboxes... Now i know this is a bad example but am trying to get the point accross in that you couldn't just have a given set of textboxes static to the page because each book has different amount of pages.
Any examples would get great.
use a reapeater control and put a place holder in the item template and bind the ids from table1. Use Itemdatabound event to capture each row and add the necessary number of controls (using loadcontrol or if its just textbox then create an instance of it) from table2 and add it to the place holder.
This should be pretty straight forward but I can't seem to get my newbie mind around it. I have a ASP.net page that needs to create a new database entry based on user input from a web form.
One control in the form is a DropDownBox that is databound to a LinqDataSource whose context is a LinqToSQL data class. The table it is bound to is the default ASP.net aspnet_Users table.
So I have this drop down list that displays all of the users stored in that table. I have a table called Events that has a foreign key relationship with aspnet_Users (each Event has a aspnet_User) and so I need that aspnet_Users UserId value to create a new Event object. How do I get this value from the selected item in the drop-down box? I'm sure this is much simpler than I'm making it.
Can you post some code of how you're binding this?
If it is bound to the user properly, you should be able to do the following.
UserClass user = MyDropDown.SelectedValue as UserClass;
Just substitute the actual class name for the user and the proper name for the dropdown.