Solved

PageIndex in FormView after deletion a datarecord

Posted on 2008-10-26
7
671 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
  • 4
  • 3
7 Comments
 

Author Comment

by:Mippes
Comment Utility
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
Comment Utility
Are you using SqlDataSource to bind your FormView?
0
 

Author Comment

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

Thanks
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 22

Expert Comment

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

Author Comment

by:Mippes
Comment Utility
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
Comment Utility
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
Comment Utility
Hi,
You were right. I don't know why I tried only the Page_Load Event.

Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now