Answered by:
Possible to use the same webform for viewing and editing?

Question
-
User-1641185037 posted
I have a module in my application that allows the user to view and edit customer data. When the user first visits the page, I display a list of customers in my grid. When the user clicks on a customer, he sees the customer form (ViewCustomer.aspx) which shows him all the data in non-editable mode. If he clicks on the edit or add button, he goes to another form (EditCustomer.aspx) which allows him to add and edit records.
I'm wondering if it is possible for me to combine both pages (EditCustomer.aspx and ViewCustomer.aspx) into one. This way, when my user wants me to modify the layout of the form, I only have to do the change in one page. But I do have many dropdownlists in my EditCustomer.aspx. E.g. I have a field that stores the customer's organisation - in EditCustomer.aspx it is a dropdownlist that stores the organisation's ID, while in ViewCustomer.aspx it is a textbox that displays the organisation's name.
Is it possible to convert textboxes to dropdownlists, and vice versa, or do I need to dynamically generate the controls on every page_load event?
Is it considered a good practice to things this way or is there a better way to do things that I am unaware of?
Thank you.
Saturday, October 28, 2006 10:38 AM
Answers
-
User-503940700 posted
You can have a single FormView with custom defined template to edit data in any format you want. Check this link for details on Formview:
msdn.microsoft.com/en-US/library/fyf1dk77.aspx
You can even use the multiview control, it acutally depends on what is more convenient to you in the long run, there is no best practice as such.
Hope this helps,
Vivek
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 29, 2006 1:52 AM -
User1564875471 posted
you can put each part in a usercontrol and load it dynamicaly
so 1 user control for edit
and 1 for view
......
then
page.LoadControl(Virtualpath Of UC)
i recommended you to see how the following opensource portal
and search for module development
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 29, 2006 3:07 AM
All replies
-
User-503940700 posted
Hi,
You can either use Panels and turn them on/off as you go on editing individual customer details. Also, if using ASP.NET 2.0, you can use the GridView/FormView combination. In ASP.NET 1.1, you can create editable girds using EditItemTemplate for in place editing on a single page.
Hope this helps,
Vivek
Saturday, October 28, 2006 3:21 PM -
User-1641185037 posted
I am using ASP.NET 2.0. If I use the formview control, with templates for both viewing and editing data, how do I handle a large form that has several tabs? Do I need to have a formview control for each tab? I intend to use a multiview control and a 3rd party tabstrip control to handle my tabs and I'm wondering if this is the best way to implement it. Thank you.
Sunday, October 29, 2006 1:11 AM -
User-503940700 posted
You can have a single FormView with custom defined template to edit data in any format you want. Check this link for details on Formview:
msdn.microsoft.com/en-US/library/fyf1dk77.aspx
You can even use the multiview control, it acutally depends on what is more convenient to you in the long run, there is no best practice as such.
Hope this helps,
Vivek
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 29, 2006 1:52 AM -
User1564875471 posted
you can put each part in a usercontrol and load it dynamicaly
so 1 user control for edit
and 1 for view
......
then
page.LoadControl(Virtualpath Of UC)
i recommended you to see how the following opensource portal
and search for module development
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 29, 2006 3:07 AM