Gridview and Dropdown - binding?

D

Danny

Hi Group,

I am working on a simple user administration system based on VB ASP.NET and
an Access database. The database contains the folowing data:

Users:
UserID, f_UserTypeID, Name, Email
1, 1, Pat, (e-mail address removed)
2, 1, Joe, (e-mail address removed)
3, 2, Tim, (e-mail address removed)

UserType:
UserTypeID, UserType
1, Administrator
2, User

As seen here, key "UserTypeID" from table UserType is used as foreign key
"f_UserTypeID" in table Users. Being an administrator it should be possible
to alter the data in table Users. All data are represented using a GridView
and a SqlDataSource with the following SQL statement:

SELECT Users.*, UserType.* FROM (Users INNER JOIN UserType ON
Users.f_UserTypeID = UserType.UserTypeID)

When altering for example Tim's data, it should be possible to choose
whether he should be an Administrator or a User using a dropdown box.
Therefore, in the design, I have changed the column "UserType" to
TemplateField. In TemplateField -> EditItemTemplate I have placed the
dropdown box.

To update Tim's data in the database, I have defined the following SQL
statement

UPDATE [Users] SET [f_UserTypeID] = @UserType, [Name] = @Name, (e-mail address removed)
 
P

Phil H

Hi Group,

I am working on a simple user administration system based on VB ASP.NET and
an Access database. The database contains the folowing data:

Users:
UserID, f_UserTypeID, Name, Email
1, 1, Pat, (e-mail address removed)
2, 1, Joe, (e-mail address removed)
3, 2, Tim, (e-mail address removed)

UserType:
UserTypeID, UserType
1, Administrator
2, User

As seen here, key "UserTypeID" from table UserType is used as foreign key
"f_UserTypeID" in table Users. Being an administrator it should be possible
to alter the data in table Users. All data are represented using a GridView
and a SqlDataSource with the following SQL statement:

SELECT Users.*, UserType.* FROM (Users INNER JOIN UserType ON
Users.f_UserTypeID = UserType.UserTypeID)

When altering for example Tim's data, it should be possible to choose
whether he should be an Administrator or a User using a dropdown box.
Therefore, in the design, I have changed the column "UserType" to
TemplateField. In TemplateField -> EditItemTemplate I have placed the
dropdown box.

To update Tim's data in the database, I have defined the following SQL
statement

UPDATE [Users] SET [f_UserTypeID] = @UserType, [Name] = @Name, (e-mail address removed)
 
S

Steven Cheng[MSFT]

Thanks for Phil's input.

Hi Danny,

I agree with Phil that for your scenario, since the select data record set
are from two joined table, it it not quite suitable to use automatic update
here. Automatic generated update will work well for a single table or
updatable view scenario. You may consider hook those updating events of the
GridView and manually do the update (to the two tables with the proper
parameters)

BTW, for AccessDataBase, we can use "SqlDataSource" to connect it as long
as the correct OLEDB provider is choosed:)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: Phil H <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
Subject: Re: Gridview and Dropdown - binding?
Date: Wed, 28 Nov 2007 10:10:10 -0800 (PST)

Hi Group,

I am working on a simple user administration system based on VB ASP.NET and
an Access database. The database contains the folowing data:

Users:
UserID, f_UserTypeID, Name, Email
1, 1, Pat, (e-mail address removed)
2, 1, Joe, (e-mail address removed)
3, 2, Tim, (e-mail address removed)

UserType:
UserTypeID, UserType
1, Administrator
2, User

As seen here, key "UserTypeID" from table UserType is used as foreign key
"f_UserTypeID" in table Users. Being an administrator it should be possible
to alter the data in table Users. All data are represented using a GridView
and a SqlDataSource with the following SQL statement:

SELECT Users.*, UserType.* FROM (Users INNER JOIN UserType ON
Users.f_UserTypeID = UserType.UserTypeID)

When altering for example Tim's data, it should be possible to choose
whether he should be an Administrator or a User using a dropdown box.
Therefore, in the design, I have changed the column "UserType" to
TemplateField. In TemplateField -> EditItemTemplate I have placed the
dropdown box.

To update Tim's data in the database, I have defined the following SQL
statement

UPDATE [Users] SET [f_UserTypeID] = @UserType, [Name] = @Name, (e-mail address removed)
 
S

Steven Cheng[MSFT]

Hi Danny,

Any progress on this issue? Or if there is still anything need help,
welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: (e-mail address removed) (Steven Cheng[MSFT])
Organization: Microsoft
Date: Thu, 29 Nov 2007 03:31:09 GMT
Subject: Re: Gridview and Dropdown - binding?
Thanks for Phil's input.

Hi Danny,

I agree with Phil that for your scenario, since the select data record set
are from two joined table, it it not quite suitable to use automatic update
here. Automatic generated update will work well for a single table or
updatable view scenario. You may consider hook those updating events of the
GridView and manually do the update (to the two tables with the proper
parameters)

BTW, for AccessDataBase, we can use "SqlDataSource" to connect it as long
as the correct OLEDB provider is choosed:)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: Phil H <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
Subject: Re: Gridview and Dropdown - binding?
Date: Wed, 28 Nov 2007 10:10:10 -0800 (PST)

Hi Group,

I am working on a simple user administration system based on VB ASP.NET and
an Access database. The database contains the folowing data:

Users:
UserID, f_UserTypeID, Name, Email
1, 1, Pat, (e-mail address removed)
2, 1, Joe, (e-mail address removed)
3, 2, Tim, (e-mail address removed)

UserType:
UserTypeID, UserType
1, Administrator
2, User

As seen here, key "UserTypeID" from table UserType is used as foreign key
"f_UserTypeID" in table Users. Being an administrator it should be possible
to alter the data in table Users. All data are represented using a GridView
and a SqlDataSource with the following SQL statement:

SELECT Users.*, UserType.* FROM (Users INNER JOIN UserType ON
Users.f_UserTypeID = UserType.UserTypeID)

When altering for example Tim's data, it should be possible to choose
whether he should be an Administrator or a User using a dropdown box.
Therefore, in the design, I have changed the column "UserType" to
TemplateField. In TemplateField -> EditItemTemplate I have placed the
dropdown box.

To update Tim's data in the database, I have defined the following SQL
statement

UPDATE [Users] SET [f_UserTypeID] = @UserType, [Name] = @Name, (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top