Solved

Pick Database field from asp.net page and save them

Posted on 2012-03-22
7
350 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now