473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FormView ChangeMode in UpdatePanel!

149 100+
Hi Guys,

I can't get to the bottom of this one.

I have a formview in an updatepanel and I switch between ReadOnly and Edit mode. No problem the first time round but when I try on the second go to return to ReadOnly it sticks in Edit mode. Wierd!!!

Here's my code;

Expand|Select|Wrap|Line Numbers
  1. public void BtnCloseEditMode_Click(object sender, EventArgs args)
  2.         {
  3.             //Switch buttons
  4.             findControl("btnEditMode", Master).Visible = true;
  5.             findControl("btnCloseEditMode", Master).Visible = false;
  6.  
  7.             //Remove CMS Control
  8.             PlaceHolder upPanel = (PlaceHolder)findControl("CMSPlaceHolder", Master);
  9.             upPanel.Controls.Clear();
  10.  
  11.             //Turn off edit mode on clientside
  12.             //ScriptManager.RegisterStartupScript(this, this.GetType(), "turnoff", "endHighlight();", true);
  13.             //Set edit mode
  14.             //ViewState["editMode"] = "false";
  15.             //Turn off edit mode across page
  16.             foreach (EditCompView ecv in editCompList)
  17.             {
  18.                 FormView view = (FormView)findControl(ecv.ViewName, Master);
  19.                 view.ChangeMode(FormViewMode.ReadOnly);
  20.                 view.DataSource = ComponentInfo.GetComponentFromCache(Convert.ToInt32(ecv.Id));
  21.                 view.DataBind();
  22.                 view.Dispose();
  23.             }
  24.             editCompList.Clear();
  25.             //Updatepanel Updates
  26.             this.updateControl(Master);
  27.         }
Any ideas would be appreciated:)
Oct 5 '07 #1
5 5326
rsdev
149 100+
I also have this in my user control;

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Init(object sender, EventArgs e)
  2.         {
  3.             if (!Page.IsPostBack)
  4.             {
  5.                 FormView viewFC1 = (FormView)BasePage.findControl(cname, this);
  6.                 viewFC1.DataSource = ComponentInfo.GetComponentFromCache(Convert.ToInt32(this.ID));
  7.                 viewFC1.DataBind();
  8.             }
  9.         }
I think this is the problem but don't know how else to bind data when the control is loaded first time only.
Oct 5 '07 #2
rsdev
149 100+
Forget my second post. It seems in debug mode that when a press the button that calls the click event from an updatepanel. It works the first time and calls the event, but the second time it doesn't call the event but the panel still updates. Bizaare!!
Oct 5 '07 #3
rsdev
149 100+
Ok. It's not that!

I have made an ArrayList class and the foreach loop iterates through the list, but I think once it does it the first time it stops. Is there a way to reset at the end of the loop?

Expand|Select|Wrap|Line Numbers
  1. public class EditCompList : IEnumerator, IEnumerable
  2.     {
  3.         public EditCompList()
  4.         {
  5.             editCompList = new ArrayList();
  6.         }
  7.  
  8.         public ArrayList editCompList;
  9.         int position = -1;
  10.  
  11.         public void Add(EditCompView EditCompView)
  12.         {
  13.             editCompList.Add(EditCompView);
  14.         }
  15.         public void Clear()
  16.         {
  17.             editCompList.Clear();
  18.         }
  19.         public void Remove(EditCompView EditCompView)
  20.         {
  21.             editCompList.Remove(EditCompView);
  22.         }
  23.         public IEnumerator GetEnumerator()
  24.         {
  25.             return (IEnumerator)this;
  26.         }
  27.         //IEnumerator
  28.         public bool MoveNext()
  29.         {
  30.             position++;
  31.             return (position < editCompList.Count);
  32.         }
  33.  
  34.         //IEnumerable
  35.         public void Reset()
  36.         { position = 0; }
  37.  
  38.         //IEnumerable
  39.         public object Current
  40.         {
  41.             get { return editCompList[position]; }
  42.         }
  43.  
  44.     }
Oct 5 '07 #4
rsdev
149 100+
It's definitely the ArrayList position. It's telling me that the error is 'index is out of range'.
Oct 5 '07 #5
rsdev
149 100+
Ok. I fixed it by setting position = -1 on Reset().

That ArrayList class was from msdn...!
Oct 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sck10 | last post by:
Hello, I have a LinkButton that I use to open a FormView in ReadOnly mode "ShowList", and a LinkButton to open the same FormView in the Insert mode "NewRecord". If the user clicks "ShowList"...
1
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView...
3
by: Geek | last post by:
Guys, I am working on a project, and I thought using FormView will help good but I am running into a issue. What I have done is that in Form View in Footer template icluded a Link Button which...
1
by: Kyle K. | last post by:
I would like to build my data pages such that the top of the page contains a GridView showing the data with 'Enable Select = true'. Below that I would like to have a FormView, that by default is...
1
by: Trev | last post by:
Hi, I'm hoping that someone in this group can shed some light on an issue I'm having with a Formview. I have a Web User Control (.ascx) with a Formview. The Formview contains 2 Multiviews,...
4
by: Mark Olbert | last post by:
I'm trying to understand how to respond to mode changing events in a FormView control. I'm not using datasource controls, so I have to do more of the plumbing myself. Do I have to call the...
1
by: Chris | last post by:
I have a treeview control, which I use to select a row in a table which will be used to populate a formview. Depending on what node is selected in the treeview I want the formview to be either in...
1
by: Brad Baker | last post by:
I have created a usercontrol (ascx file) which contains a formview, inside of the formview I have an EditItemTemplate and an ItemTemplate. Both the EditItemTemplate and ItemTemplate have link...
5
by: J055 | last post by:
Hi I have a FormView control within a UserControl. After I DataBind I need to change the CurrentMode depending on a value from the ObjectDataSource Select method. When I do this the FormView...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.