Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PageIndex in FormView after deletion a datarecord

Posted on 2008-10-26
7
Medium Priority
?
705 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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