Solved

.net Multiple Row Form Fields Data Entry

Posted on 2016-11-16
4
35 Views
Last Modified: 2016-11-16
Hi Experts,

Is there a way in .NET to create a grid of fields (including dropdowns, text, radios etc.) where a user can enter multiple rows at once, and submit the whole grid? DataGrid?

Thanks
Steve
0
Comment
Question by:tablaFreak
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Dustin Saunders
ID: 41890315
You can create a user control with each of the items on it, and then populate your form with those controls.  Then, when you submit the changes, you can go through each control and get the values like you would with a data grid.
0
 

Author Comment

by:tablaFreak
ID: 41890342
Thanks, Dustin. And .NET doesn't choke on multiple form fields with the same name, or does the runtime engine dynamically create different field names for those controls?
0
 
LVL 12

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41890361
Since each of your 'parent' user controls is a separate object-- the 'child' controls on that are unique to each object.  So, say you load your data into a DataTable.  Then for each row, you create one of your custom controls (with all the drop downs, radios, etc.) and set each of the control's values.  Then add those controls onto a panel as you iterate through them.  Now you've got your set up, so when the time comes to wrap to commit the changes, you can iterate through each control on the panel to write back the values.

You'll need to either make the controls on the 'parent' public, or set public variables that you call (like ControlName.FirstName).  

I usually create a class for my control (with all the variables I need { get; set; })  and then pass that class on to the control when I create it.  Then on the load() event for the control, that's where I set the individual control values on the 'child' objects.  If you create a public class variable for each form, then save the changes to the class it makes it easier to write back.
0
 

Author Closing Comment

by:tablaFreak
ID: 41890476
Thanks for the help, Dustin.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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