Web Server Controls Templates - best practices

J

Jim Underwood

I am not sure if web server control templates are the way to go or not, but
I would like to get some opinions on the best way to go about this.

I have a web page where administrators will specify which users have access
to various reports. The page will display the report name and a list of
users who currently have access. The administrator will be able to add or
delete from this list of users, then save the results to the database.
Basically, I want to be able to add or remove items to this list on the
client side, and have the server recognize the additions. I would also like
to avoid postbacks to the server when not absolutely necessary.

I know how to do this with classic asp, but I am developing in .net and want
to do this the best way so others will have no trouble managing the code.

Should I be using repeaters, datalists, datagrids, or a completely different
approach?

Any advice that can be provided would be a huge help.

i.e.

Report Name: Monthly Financial Statement

Users:

John Doe
Susan Parker
Tom Clancy

<add user> <remove user> <save changes>
 
D

DKode

Alot of people get really anxious about doing postbacks to the server.
Unless you will have 1000+ people accessing this at the sametime, the
load on your server is negligable. I have had many apps that I had to
do multiple postbacks and I have never had a problem.

I would make it so, when you click the "add user" button, it sends the
reportID, userID to the server and execute an "AddUserToReport" method.

In other words, process each addition of a user to a report, right when
that one user is added. This is going to require less code on the
server side and less headache for you. If you do it the other way, you
will have to store a collection of values in the clients session, then
when they click "save changes" you'll have to iterate through the
collection and do multiple database calls anyways.

Just a suggestion, I always try to take the route that requires me to
code less, because thats less code to maintain later on, and easier to
read code.

my 2cents
 
J

Jim Underwood

Thanks.
This particular app will only have a handful of users, so the added network
traffic should be negligible.

What would you recomend using a control template, building the user list
with a loop, or some other method?
 
D

DKode

if you are talking about what method to use to populate the usercontrol
with the list of users that have access to that report, I personally
would use a datagrid, query your database to get a dataset of the users
for that report, then bind the datatable to the datagrid. then perhaps
put in a checkbox column in the datagrid, checking off users that
already have access, then as someone clicks a checkbox to add a user to
the report, attach the checkbox event and add ur code to add the user
to the database in the event handler for the checkbox.

there is always lots of different ways of solving a problem, but at
first glance and from what you described, this is the method I would
take. You might have other requirements in there that i'm not aware of.
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top