Solved

PageIndex in FormView after deletion a datarecord

Posted on 2008-10-26
7
697 Views
Last Modified: 2012-05-05
Hi,
In the ReadOnly mode of my FormView I can delete datarecords. Thus I go to the index of the datarecord
which can be deleted e.g. PageIndex=10.
After that the data record is deleted the FormView shows the Pageindex=9, however I would like it
indicates the pageindex=0.
In the FormView1_ItemDeleted event I have tried to set the FormView.PageIndex, but without success.

Thanks
Mippes
Private Sub FormView1_ItemDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewDeletedEventArgs) Handles FormView1.ItemDeleted
        Me.DropDownList1.Items.Clear()
        Me.DropDownList1.AppendDataBoundItems = True
        Me.DropDownList1.Items.Add(New ListItem("--- Select ---", "none"))
        Me.FormView1.PageIndex = 0
End Sub

Open in new window

0
Comment
Question by:Mippes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:Mippes
ID: 22812237
Hi,
I found a solution for my problem. I am in doubt if it don't give a better solution.
Would be good if someone could give a comment to it.

Thanks
Mippes
Private Sub FormView1_ItemDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewDeletedEventArgs) Handles FormView1.ItemDeleted
    Me.DropDownList1.Items.Clear()
    Me.DropDownList1.AppendDataBoundItems = True
    Me.DropDownList1.Items.Add(New ListItem("--- Select ---", "none"))
    Session("Deleted") = "True"
End Sub
 
Private Sub FormView1_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.PageIndexChanged
    If (Session("Deleted")) = "True" Then
        Me.FormView1.PageIndex = 0
    End If
        Session("Deleted") = "False"
End Sub

Open in new window

0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22823387
Are you using SqlDataSource to bind your FormView?
0
 

Author Comment

by:Mippes
ID: 22824360
Hi,
No I am using a ObjectDataSource which I formed from a stongly typed DataSet to bind
to my FormView.

Thanks
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 22

Expert Comment

by:prairiedog
ID: 22824960
Try rebinding your FormView after deleting an item:
Me.FormView1.PageIndex = 0
Me.FormView1.DataBind()
0
 

Author Comment

by:Mippes
ID: 22825434
Hi,
Would be interesting in which Event. In the Page_Load Event does it not function, also in both Postbacks.

Thanks
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 22825457
As mentioned in my last post, it is after an item is deleted, so it will be in FormView1_ItemDeleted event handler.
0
 

Author Comment

by:Mippes
ID: 22825837
Hi,
You were right. I don't know why I tried only the Page_Load Event.

Thanks
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question