Link to home
Start Free TrialLog in
Avatar of mugsey
mugseyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to switch between view and edit mode in an asp.net 2.0 web form

Currently I have a web form that loads a lot of text boxes with values from asp.net membership

EG

 this.txtEmail.Text = _msu.Email;

What is the best approach for making this web form editable. ie, load the form then switch the text boxes between edit and view mode
Avatar of samtran0331
samtran0331
Flag of United States of America image

have a look at the formview control
http://msdn2.microsoft.com/en-us/library/fyf1dk77.aspx
google "asp.net formview" for more
Avatar of mugsey

ASKER

Can I use this without the object data source?
yes....think of the formview just like a gridview that shows only one record.
and like the gridview, you can have itemtemplate and edititemtemplate section...
you can place a label in itemtemplate and a textbox in edititemtemplate...and to set the data without using a datasource, you can use "findcontrol" (just like gridview)... to get to the label/textbox to set the values
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mugsey

ASKER

Has anyone got an example with formview WITHOUT an object data source??  :-)
...you have the membership object...which I think you can use as the datasource...
Avatar of mugsey

ASKER

Well its because I am using a customised membership provider and it causes me pain if I try and use the object data source
Avatar of NPDAdmin
NPDAdmin

Use a DetailsView instead.  Are you connecting to Active Directory (LDAP)?  If not, why can't you just use SqlDataSource?

to access textboxes
TextBox txtEmail = (TextBox)DetailsView1.FindControl("txtemmail");