Solved

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

Posted on 2010-11-16
2
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 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