Solved

Pick Database field from asp.net page and save them

Posted on 2012-03-22
7
365 Views
Last Modified: 2012-03-22
Ok here is what I am trying to accomplish, I have a table with lots of fields for registration of different products.  Each time they add a new product they want to be able to save the fields that they want to fill out in a db so that I do not have to hard code them each time with code.  So how can users pick which DB fields they want to save information agianst and save in table so that when they go to the page it pulls up only the fields that they picked to fill out?

So they add a product called WIFI
WIFI has the following properties that they want to capture
IP,
dataplan,
range
carrier
so they pick these fields from the registration table and save to antoher table that keeps the fields they picked so when they open the page it only shows the fields they picked.

IS this doable and can someone give me some guidlines on how to do and I can figure out most from there.
0
Comment
Question by:kdeutsch
  • 3
  • 3
7 Comments
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 100 total points
ID: 37753266
I would say you want a table for Product, with an extra table for ProductDataColumn

ProductDataColumn
Name
<Any other fields you need to describe or validate the data>

Relation:
Product one to many ProductDataColumn


You also need a table to store the data.  
ProductData:
ID
ProductID  (FK to Product)
ProductDataColumnID (FK to ProductDataColumn)
Data

Product one to many ProductData (each column has it's own row.)  Obviously you have to store all the extra data as strings, so converting where needed.
0
 
LVL 9

Accepted Solution

by:
gery128 earned 400 total points
ID: 37753335
I could think this way only to achieve this:
(Lets say Table name is Product and you need to allow most of the field as Null)
1. Display all the fields of Product-table to user (using InformationSchema - ColumnName)
2. User will check fields relevant to it. And will click next.
3. Now you have user's choice about the Product-table fields (say, for WIFI he has chosen
IP,
dataplan,
range
carrier
but he ignored weight, length, type, resolution etc.)
So you will forward this chosen fields to next page and populate text-boxes, drop-downs or other controls for that fields with Labels off-course.
4. Once user fills, you will save/insert those 4-5 fields in Product table as record, inserting only relevant columns and ignoring the rest of it (that's why we need keep most of the fields null except ProductId or Unique key for that record.)
5. You have record in Product table, display it to user by checking which column has data and populate only those labels to show it to user.

Let me know if it fulfills your criteria.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 37753422
The only problem with gery128's solution is that you have to know all the field types in advance.  Otherwise you will be updating the columns on that table whenever you encounter a product that has a new feature/specification.  If that's okay, then that's the way to go.

On the other hand, my approach treats the extra columns as data, so you can add columns without refactoring the database structure when you want to add a new product with different features that need to be listed.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:kdeutsch
ID: 37753767
Hi,
The database is  already predetermined based of off the characteristics of IT products,  so when they insert a new IT Product they pick and save the fields from the DB they plan on using, so that it pops up on the page each time they go to it.  Then they can save the data and move on.
So it sounds like I can query the schema of a table and from here they will need to save which ones they pick into another db as the chosen fields from which the page will load these fields and tehn save the data to the table.
0
 

Author Comment

by:kdeutsch
ID: 37753796
Ok,
Just so I am on right track, I found out how to query the table Schema, now I need to pick the columns I want, and then save these columns in another DB with the product and its accompany fields names from which I will query to put textboxes on the asp page which allows them to save the data.  Right track or wrong.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 37753921
Sounds like you are on track for the approach suggested by gery128.  It's certainly a good way to approach the problem.
0
 

Author Closing Comment

by:kdeutsch
ID: 37754678
Thanks for the good start, i have it all selecting and saving in a table. Next the harder part.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LINQ Select all records by MAX data syntax help 1 19
ASP Repeater control - onl;y show if flag is true 7 16
jquery tab header text 1 23
Input parameteres to DragOver 2 20
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question