Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

PageIndex in FormView after deletion a datarecord

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
Mippes
Asked:
Mippes
  • 4
  • 3
1 Solution
 
MippesAuthor Commented:
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
 
prairiedogCommented:
Are you using SqlDataSource to bind your FormView?
0
 
MippesAuthor Commented:
Hi,
No I am using a ObjectDataSource which I formed from a stongly typed DataSet to bind
to my FormView.

Thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
prairiedogCommented:
Try rebinding your FormView after deleting an item:
Me.FormView1.PageIndex = 0
Me.FormView1.DataBind()
0
 
MippesAuthor Commented:
Hi,
Would be interesting in which Event. In the Page_Load Event does it not function, also in both Postbacks.

Thanks
0
 
prairiedogCommented:
As mentioned in my last post, it is after an item is deleted, so it will be in FormView1_ItemDeleted event handler.
0
 
MippesAuthor Commented:
Hi,
You were right. I don't know why I tried only the Page_Load Event.

Thanks
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now