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
Solved

PageIndex in FormView after deletion a datarecord

Posted on 2008-10-26
7
686 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 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