Solved

Pick Database field from asp.net page and save them

Posted on 2012-03-22
7
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

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:…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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