Solved

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

Posted on 2010-11-16
2
225 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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