Leaving FormView state without cancelling

S

sck10

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" then a GridView opens up and
they can then select a record to view the record in the FormView. If they
select the "NewRecord" LinkButton, the same FormView opens in Insert mode.

The problem that I am having is that when the user clicks the "NewRecord"
LinkButton to open the form in Insert mode and then click the "ShowList"
LinkButton. The GridView will open, but when I select a record to view, the
FormView doesn't show. I have to re-select the "NewRecord" LinkButton and
then click the "Cancel" button at the bottom of the FormView.

Once I do this, the FormView will work properly in the ReadOnly mode. I
need to show both LinkButtons, so my question is how can I call the cancel
Insert mode event if a user clicks on a LinkButton before canceling the
Insert view?
--
Thanks in advance,

sck10


Protected Sub lbtnCustRev_Command(ByVal sender As Object, ByVal e As
CommandEventArgs)
If e.CommandName = "ShowList" Then
Me.fvCustRev.ChangeMode(FormViewMode.ReadOnly)
ElseIf e.CommandName = "NewRecord" Then
Me.fvCustRev.ChangeMode(FormViewMode.Insert)
End If
End Sub
 
S

Shaun McDonnell

You should be able to accomplish what you want by using the events attached
to the FormView such as "ModeChanged" or "ModeChanging"

Let me know if you have anymore questions.

Shaun McDonnell
 
S

Steven Cheng[MSFT]

Hi Sck10,

Thanks you for posting.

As for the FormView displaying status issue, I think it is likely caused by
the FormView 's Mode doesn't been changed correctly when you swtich to the
ShowList mode. Since after the user click "NewRecord" button, the FormView
turn into "Insert" mode, if we directly click "ShowList" at that time, the
FormView is still under "Insert" mode, this cause the problem. I think you
can consider use the FormView.ChangeMode method to explicitly set the
FormView's currentMode to "Readonly", e.g:


protected void LinkButtonShowList_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
FormView1.ChangeMode(FormViewMode.ReadOnly);
}

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top