Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
See more:
Hi :) I have some form data that is stored in the database and each form has a ref num..So here is the problem

Suppose i have four ref numbers of the forms say 001,002,003,004 I want 001 and 003 grouped together and generate a number say 1,then i want 002 and 004 grouped together and generate a number say 2.

So in the DB it will look like
C#
Name Desig Ref ID
xyz   abc  001  1
abc   asd  003  1
def   sed  002  2
fgh   hjk  004  2

Can someone let me know how to implement this on c# and SQL..I just want the basic logic on how to do this and not the code...should i use datagrid?if so then how do i work on grouping the ref numbers?
Posted
Updated 11-Sep-13 6:12am
v2
Comments
phil.o 11-Sep-13 12:12pm    
What is the logic behind? You gave an example but it is far from describing the logic.
For example, what about if your 'ref numbers' are 002, 005, 010, 027 and 152? What is the logic deciding of the grouping?
Member 10066916 11-Sep-13 12:13pm    
that is upto the admin to group whichever ref numbers he/she wants to
Member 10066916 11-Sep-13 12:14pm    
the admin can group 002 or 005 or maybe 010 or 152 anything...
i.fakhari 11-Sep-13 13:04pm    
hithe user makes groups or there are some groups and user divide data?
Member 10066916 11-Sep-13 23:08pm    
there are some groups and the admin will divide the data

1 solution

On the database side, you need a new table for the groups. That table has an automatically generated ID (autoincrement) as the group's ID (which is not shown in your example, only used internally). You may add extra columns for e.g. a description of the group.
Another new table stores the relation of your existing data with the group: it contains the ID of the group and the ID ("ref") of your data.
In the C# application, you could use a Dictionary<Group, YourData>; for handling that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900