如何将数据从网格导出到其他页面上的其他网格?

时间:2012-02-14 08:34:18

标签: asp.net c#-4.0

您好我有应用程序,我必须将页面上的网格数据导出到其他页面上的另一个网格..

我的逻辑是我有带复选框的网格.........我有一个管理员和3个用户...我有一个页面用于“管理员”和一个页面用于其他“3个用户”时他们登录他们被带到他们自己的页面.....当管理员登录他有网格填充数据与复选框.......

       1)now the "admin" logins and visits his page his page looks like this
        he has a button called assign work and a dropdownlist binded with three users                      names.
       2)The admin selects some data using checkbox and selects the username from the dop down list ,and clicks on assign work button.
        3)In the same way he does for other two users....
       4)Here all the users have same page when user 1 logins he should be seeing only the  work assigned to him by admin,when user two logins his work should be shown.

任何1可以告诉我如何开始这个...我应该如何准备数据库并使用它.... 并且可以向我提供所需的代码......对我有帮助......

先谢谢你们......

2 个答案:

答案 0 :(得分:1)

供您参考,请检查以下内容。它不是完美的解决方案,需要修改一些参考完整性等。只是为您提供一些想法。

- 数据库设计

-- user information
create table USERS (USER_ID INT IDENTITY PRIMARY KEY, USER_NM NVARCHAR(100) NOT NULL)
insert into USERS values ('Admin');
insert into USERS values ('User 1');
insert into USERS values ('User 2');
insert into USERS values ('User 3');

-- role description
create table ROLES_DESC (ID INT IDENTITY PRIMARY KEY, ROLE_ID INT NOT NULL, ROLE_DESC NVARCHAR(50) NOT NULL)
INSERT INTO ROLES_DESC VALUES (1,'Admin');
INSERT INTO ROLES_DESC VALUES (2,'User');

-- assing each user to at least one role
create table ROLES (ID INT IDENTITY PRIMARY KEY, USER_ID INT NOT NULL, ROLE_ID INT NOT NULL)
insert into ROLES (1,1) -- admin
insert into ROLES (2,2) -- User 1
insert into ROLES (3,2) -- User 2
insert into ROLES (4,2) -- User 3


-- task infomration
create table TASKS (ID INT IDENTITY PRIMARY KEY, TASK_DESC VARCHAR(100))
insert into TASKS values ('C# Programming');
insert into TASKS values ('Database Programming');
insert into TASKS values ('Match Homework');


-- admin can assing task to each user.. save here
create table ASSINGMENTS (ID INT IDENTITY PRIMARY KEY, USER_ID INT NOT NULL, TASK_ID INT NOT NULL, ASSING_DT DATETIME DEFAULT GETDATE())
insert into ASSINGMENTS (USER_ID,TASK_ID) values (2,1);
insert into ASSINGMENTS (USER_ID,TASK_ID) values (2,2);
insert into ASSINGMENTS (USER_ID,TASK_ID) values (3,1);
insert into ASSINGMENTS (USER_ID,TASK_ID) values (4,3);

---------在aspx中你有管理页面和用户页面 在管理页面中,使用templatefiled列(用户下拉列表和任务下拉列表) 用户下拉列表

SELECT USER_ID, USER_NM) FROM USERS WHERE ID <> 1 -- (only select non-admin user)

for task下拉列表

SELECT ID, TASK_DESC FROM TASKS

- 当更新任务到每个用户事件时,从网格读取数据并保存到ASSINGMENTS表

对于用户页面 -

只需从ASSERSMENTS表中读取数据,使用USERS,TASKS表连接并绑定到gridview

SELECT A.TASK_ID, T.TASK_DESC, A.ASSING_DT
FROM ASSINGMENTS A
INNER JOIN TASKS T ON (A.TASK_ID = T.ID)
WHERE A.USER_ID = 2

答案 1 :(得分:0)

这取决于您的数据库和架构。 您应该创建一个包含

Work
  • ID int
  • CreatedBy(管理员ID)
  • CreatedAt datetime
  • 主题和/或备注varchar null

然后我会使用1-n关系表WorkAssignment来存储用户分配和管理员选择的数据(应该做什么)

  • ID int
  • fiWorker(已分配用户的ID)
  • fiWork(Work中记录的ID)
  • 主题和/或备注varchar null(如果您以后想要为此用户留言)
  • fiData int(链接到GridView的记录)