Solved

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

Posted on 2010-11-16
2
195 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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

12 Experts available now in Live!

Get 1:1 Help Now