ListView Control Update not working

Posted on 2011-04-27
Last Modified: 2012-05-11
I have a search engine on my site which selects from a database and allows user to edit the records  , all works fine , but basically I need to programatically define the "select all ' command so my datalist shows all records  from the db . My current code is working but the issue is that once I try to edit the record, it takes me to the first page and does not go into edit mode...
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Providers.mdb"
        DeleteCommand = " DELETE * From [tbl_Providers] WHERE [ID] = ?" 
        UpdateCommand="UPDATE [tbl_Providers] SET [Provider_Type] = ?, [Last_Name] = ?, [First_Name] = ?, [Prof_Designation] = ?, [Group_Business_Name] = ?, [Specialty] = ?, [Specialty2] = ?, [Address] = ?, [Address2] = ?, [City] = ?, [State] = ?, [Zip] = ?, [Phone] = ?, [Fax] = ? WHERE [ID] = ? "    
        SelectCommand="SELECT [Id],[First_Name],[Last_Name],[Prof_Designation], [Specialty], [Specialty2],[Address], [Address2], [City], [State], [Zip], [Phone], [Fax],[Provider_Type],[Group_Business_Name] FROM [tbl_Providers] WHERE  
        ((@First_Name IS NULL OR First_Name LIKE '%' +  @First_Name + '%') OR
        (@Last_Name IS NULL OR Last_Name LIKE '%' +  @Last_Name + '%')) AND
       ( (@Specialty IS NULL OR Specialty LIKE '%' + @Specialty + '%') OR
        (@Specialty IS NULL OR Specialty2 LIKE '%' + @Specialty + '%'))" 
            <asp:ControlParameter ControlID="providerTextBox" Name="First_Name" PropertyName="Text"
                Type="String" ConvertEmptyStringToNull="true" />
            <asp:ControlParameter ControlID="providerTextBox" Name="Last_Name" PropertyName="Text"
                Type="String" ConvertEmptyStringToNull="true" />
            <asp:ControlParameter ControlID="specialityDropDown" Name="Specialty" PropertyName="SelectedValue"
                Type="String" ConvertEmptyStringToNull="true" />

Open in new window

Protected Sub ListView1_PagePropertiesChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.PagePropertiesChangingEventArgs) Handles ListView1.PagePropertiesChanging
        Dim pager As DataPager = DirectCast(DirectCast(sender, ListView).FindControl("DataPager1"), DataPager)
        'pager.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
        Dim sql1 As String
        sql1 = "SELECT [Id],[First_Name],[Last_Name],[Prof_Designation], [Specialty], [Specialty2],[Address], [Address2], [City], [State], [Zip], [Phone], [Fax],[Provider_Type],[Group_Business_Name] FROM [tbl_Providers]"
        AccessDataSource1.SelectCommand = sql1

    End Sub

Open in new window

Question by:TonyReba
    LVL 7

    Expert Comment

    could you post the full page code please, I'm also wondering if you need to qualify the PagePropertiesChanging event to only fire that selectCommand when it's not in Edit mode
    LVL 9

    Author Comment

    How would I declare this event?
    LVL 7

    Accepted Solution

    check the event list in the control properties

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    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ā€¦
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn how to dynamically set the form action using jQuery.

    729 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

    17 Experts available now in Live!

    Get 1:1 Help Now