Solved

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

Posted on 2010-11-16
2
214 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:Jeenyusx10
2 Comments
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 34153626
Hi,

It is not working because you have not specified any update or insert parameters for the datasource, only for the select command.

/Carl.
0
 

Author Comment

by:Jeenyusx10
ID: 34156845
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!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 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