We help IT Professionals succeed at work.

ListView Control Update not working

279 Views
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 + '%'))" 
        
        CancelSelectOnNullParameter="False">
        
        <SelectParameters>
            <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" />
     
        </SelectParameters>

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

Comment
Watch Question

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

Author

Commented:
How would I declare this event?
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.