Search code examples
c#asp.netentity-frameworkdetailsview

Go to insert mode when DetailsView has no data


I'm very new to .NET 4 web development, and I'm trying to figure out how this should work. On my page, I have a drop down list, a textbox, a search button, and a detailsview which is hooked up by a Entity Data Source. The entity source and details view is setup to allow automatic inserting and updating. Here is the markup for my query extender:

   <asp:QueryExtender ID="QECustFilter" runat="server" TargetControlID="ClaimEntitySource" >
            <asp:PropertyExpression>
                <asp:ControlParameter ControlID="ddlCustomer" Name="CTCustomerSubID" PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="txtClaim" Name="CustClaimID" PropertyName="Text" />
            </asp:PropertyExpression>
        </asp:QueryExtender>

As you can see, its filtered by what they select in the drop down, and what text is in the text box. Here's what I want to happen:

  1. User selects value from drop down
  2. User types text into text box
  3. User clicks search button.
  4. If a record is found that matches criteria, allow user to edit record in details view.
  5. If no record is found, force details view to go into insert mode.

Is this possible?


Solution

  • I figured it out. If anybody cares the heres the code behind:

    Listview.ChangeMode(FormViewMode.Edit);