Link to home
Create AccountLog in
Avatar of Jeenyusx10
Jeenyusx10

asked on

Formview buttons - Am i supposed to have to program them?

I have a form view without a gridview. I've searched relentlessly on the net to find an example that does not use a gridview..it seems like these two go hand in hand...

I have a dropdownlist with a list of customer names. However, index position 0 is "---New Customer---"

So depending on what is selected in this combo box, when one clicks a select button it displays the proper formview mode...Everything works fine..

When I select a customer and click select, it bring up edit mode.. this is fine.. I make a change and hit update and nothing happens.. however, the events do fire but as I understand it, these buttong are pre programmed to do their jobs... right?

I also have this problem inserting a new customer with formview... the insert button does nothing. however the cancel buttons do work..

So my question is, do I need to program these buttons to make them work, or do I have parameters wrong or something?
<% this is the data source and parameters used by the form view ----%>    

<asp:SqlDataSource ID="customerDetailsDS" runat="server" ConnectionString="<%$ ConnectionStrings:ITP244ConnectionString %>"
        SelectCommand="SELECT Name, Address1, Address2, City, State, ZipCode, PhoneNumber, StudentID, CustomerID 
                        FROM Student.Customer 
                        WHERE (StudentID = @StudentID) 
                        AND (CustomerID = @CustomerID)" 
                        ConflictDetection="CompareAllValues" 
                        InsertCommandType="StoredProcedure" 
                        InsertCommand="Student.InsertCustomer" 
                        ProviderName="System.Data.SqlClient" 
                        UpdateCommandType="StoredProcedure" 
                        UpdateCommand="Student.UpdateCustomer">
        <SelectParameters>
            <asp:SessionParameter Name="StudentID" SessionField="StudentID" />
            <asp:ControlParameter Name="CustomerID" ControlID="customerNameDDL" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>


<%--------THis is the formview control-----------------%>

<asp:FormView ID="customerFormView" runat="server" 
                        DataKeyNames="StudentID,CustomerID" DataSourceID="customerDetailsDS"
                        EnableModelValidation="True" Font-Names="Corbel" Font-Size="Medium" 
                        ForeColor="#4A4A4A" Width="490px" Font-Bold="True">
                        <EditItemTemplate>
                            <div class="itemTemplateWrapper">
                                <div class="formViewLeftDiv">
                                    Name:<br />
                                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' SkinID="LongBox" /><br /><br />
                                    Address 1:<br />
                                    <asp:TextBox ID="Address1TextBox" runat="server" Text='<%# Bind("Address1") %>' SkinID="LongBox" /><br /><br />
                                    Address 2:<br />
                                    <asp:TextBox ID="Address2TextBox" runat="server" Text='<%# Bind("Address2") %>' SkinID="LongBox" /><br /><br />
                                    City:<br />
                                    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' SkinID="LongBox" /><br /><br />
                                </div>
                                <div class="formViewRightDiv">
                                    State:<br />
                                    <asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>' SkinID="ShortBox" /><br /><br />
                                    ZipCode:<br />
                                    <asp:TextBox ID="ZipCodeTextBox" runat="server" Text='<%# Bind("ZipCode") %>' SkinID="ShortBox" /><br /><br />
                                    Phone #:<br />
                                    <asp:TextBox ID="PhoneNumberTextBox" runat="server" Text='<%# Bind("PhoneNumber") %>'
                                        SkinID="LongBox" /><br /><br />
                                </div><br />
                                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                                    Text="Update" CssClass="updateFormViewButtons" />
                                &nbsp;&nbsp;
                                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel" CssClass="updateFormViewButtons" />
                            </div>
                            
                        </EditItemTemplate>
                        <EmptyDataTemplate>
                            Empty
                        </EmptyDataTemplate>
                        <InsertItemTemplate>
                            <div class="itemTemplateWrapper">
                                <div class="formViewLeftDiv">
                                    Name:<br />
                                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' SkinID="LongBox" /><br /><br />
                                    Address 1:<br />
                                    <asp:TextBox ID="Address1TextBox" runat="server" Text='<%# Bind("Address1") %>' SkinID="LongBox" /><br /><br />
                                    Address 2:<br />
                                    <asp:TextBox ID="Address2TextBox" runat="server" Text='<%# Bind("Address2") %>' SkinID="LongBox" /><br /><br />
                                    City:<br />
                                    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' SkinID="LongBox" /><br /><br />
                                </div>
                                <div class="formViewRightDiv">
                                    State:<br />
                                    <asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>' SkinID="ShortBox" /><br /><br />
                                    ZipCode:<br />
                                    <asp:TextBox ID="ZipCodeTextBox" runat="server" Text='<%# Bind("ZipCode") %>' SkinID="ShortBox" /><br /><br />
                                    Phone #:<br />
                                    <asp:TextBox ID="PhoneNumberTextBox" runat="server" Text='<%# Bind("PhoneNumber") %>'
                                        SkinID="LongBox" /><br /><br />
                                    Student ID:
                                    <asp:TextBox ID="StudentIDTextBox" runat="server" Text='<%# Eval("StudentID") %>' SkinID="ShortBox" /><br /><br />
                                </div><br />
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                                Text="Insert" CssClass="updateFormViewButtons" />
                            &nbsp;
                            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                Text="Cancel" CssClass="updateFormViewButtons" />
                        </div>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            Name:
                            <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
                            <br />
                            Address1:
                            <asp:Label ID="Address1Label" runat="server" Text='<%# Bind("Address1") %>' />
                            <br />
                            Address2:
                            <asp:Label ID="Address2Label" runat="server" Text='<%# Bind("Address2") %>' />
                            <br />
                            City:
                            <asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>' />
                            <br />
                            State:
                            <asp:Label ID="StateLabel" runat="server" Text='<%# Bind("State") %>' />
                            <br />
                            ZipCode:
                            <asp:Label ID="ZipCodeLabel" runat="server" Text='<%# Bind("ZipCode") %>' />
                            <br />
                            PhoneNumber:
                            <asp:Label ID="PhoneNumberLabel" runat="server" Text='<%# Bind("PhoneNumber") %>' />
                            <br />
                            StudentID:
                            <asp:Label ID="StudentIDLabel" runat="server" Text='<%# Bind("StudentID") %>' />
                            <br />
                            <asp:LinkButton ID="EditButton" runat="server" CssClass="updateFormViewButtons" 
                                CommandName="Edit" CausesValidation="False" onclick="EditButton_Click">Edit</asp:LinkButton>
                        </ItemTemplate>
                    </asp:FormView>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of carlnorrbom
carlnorrbom
Flag of Sweden image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Jeenyusx10
Jeenyusx10

ASKER

Everything I read said the formview used the original values as parameters.. I figured since the fields were bound that it would some how figure it out on its own.. Thanks!