Solved

PageIndex in FormView after deletion a datarecord

Posted on 2008-10-26
7
683 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
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 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