Thursday, April 28, 2011

Mode is not changing in detailsview

hi in details view once i click edit mode. all the controls are getting into edit mode. i make the changes and give update data is updated in database . but still all the controls are in edit mode only "actaully once we give click then update then i should again gone to read only mode means all the values should again be showing in label field"

i am doing this in .cs file only no sqldatadource is used or object datasource

right now this feature is not happening to me. what is the issue here?

looking forward for an solution thank you

From stackoverflow
  • Since you aren't using any built-in code to do the update, you probably need to change the display mode manually during your update.

    myDetailsView.ChangeMode( DetailsViewMode.ReadOnly );
    prince23 : ya added this line of code in ItemUpdating event that is after i do update to database: { myDetailsView.ChangeMode( DetailsViewMode.ReadOnly ); } but i get an error telling that as you are in edit mode you cannot do readonly here
  • you need to put this code in itemupdated event of detailsview rather itemupdating event.

    prince23 : hi Muhammad Akhtar i have put this code in itemupdated event { yourDetailsView.ChangeMode(DetailsViewMode.ReadOnly); } but this event is not getting fired only after itemupdating event. is exceuted
    prince23 : i am placing my detailsview control update panel and have set the update mode ="conditional" there
    prince23 : protected void DetailsView1_ItemUpdating(object sender, DetailsViewInsertEventArgs e) { Updatedetailsview(); DetailsView1.ChangeMode(DetailsViewMode.ReadOnly); BindDetailsView(); } } this was the code which finally made my probmlem solve we can put this code itemupdating event. only DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);


Post a Comment