Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2006, 02:31 PM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Form View / Control Parameters

Hey Guys!
I am having some issues when attempting to use the formview object. Bascially, I am trying to access a insterted drop down list in the form view object (when inserting) using:

<asp:ControlParameter ControlID="ddlOrigin" DefaultValue="0" Name="id_origen" PropertyName="SelectedValue" />

This will work with anything outside of the the formview, but nothing inside of it. Can anyone tell me why and how to fix it. I get the error that it cannot find a control with the id of "ddlOrigin"...

Here is the code that I am looking at...

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModifyEmployeeInformatino.aspx.cs" Inherits="ModifyEmployeeInformatino" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Modifiy Employee</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
            DataTextField="lname" DataValueField="id_employee">
        </asp:DropDownList>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IraqEmployeeRosterConnectionStri ng %>"
            SelectCommand="SELECT [id_employee], [fname], [lname] FROM [Employee] ORDER BY [lname]">
        </asp:SqlDataSource>
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="id_employee" DataSourceID="SqlDataSource2">
            <EditItemTemplate>
                fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>'>
                </asp:TextBox><br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>'>
                </asp:TextBox><br />
                id_origin:
                <asp:DropDownList ID="ddlOrigin" runat="server" DataSourceID="SqlDataSource3"
                    DataTextField="origin" DataValueField="id_origin">
                </asp:DropDownList><br />

                life_support:
                <asp:TextBox ID="life_supportTextBox" runat="server" Text='<%# Bind("life_support") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="Update">
                </asp:LinkButton>
                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </EditItemTemplate>
            <InsertItemTemplate>
                fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>'>
                </asp:TextBox><br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>'>
                </asp:TextBox><br />
                id_origin:
                <asp:TextBox ID="id_originTextBox" runat="server" Text='<%# Bind("id_origin") %>'>
                </asp:TextBox><br />
                life_support:
                <asp:TextBox ID="life_supportTextBox" runat="server" Text='<%# Bind("life_support") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Insert">
                </asp:LinkButton>
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </InsertItemTemplate>
            <ItemTemplate>
                id_employee:
                <asp:Label ID="id_employeeLabel" runat="server" Text='<%# Eval("id_employee") %>'>
                </asp:Label><br />
                fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Bind("fname") %>'></asp:Label><br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Bind("lname") %>'></asp:Label><br />
                Origen:
                <asp:Label ID="id_originLabel" runat="server" Text='<%# Bind("origin") %>'></asp:Label><br />
                life_support:
                <asp:Label ID="life_supportLabel" runat="server" Text='<%# Bind("life_support") %>'>
                </asp:Label><br />
                <asp:LinkButton ID="NewButton" runat="server" CausesValidation="True" CommandName="New"
                    Text="New">
                </asp:LinkButton>
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="Edit">
                </asp:LinkButton>

            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:IraqEmployeeRosterConnectionStri ng %>"
            DeleteCommand="DELETE FROM [Employee] WHERE [id_employee] = @id_employee" InsertCommand="INSERT INTO [Employee] ([fname], [lname], [id_origin], [life_support]) VALUES (@fname, @lname, @id_origin, @life_support)"
            SelectCommand="SELECT dbo.Employee.id_employee, dbo.Employee.fname, dbo.Employee.lname, dbo.Employee.id_origin, dbo.Employee.life_support, dbo.Origin.origin FROM dbo.Employee INNER JOIN dbo.Origin ON dbo.Employee.id_origin = dbo.Origin.id_origin WHERE (dbo.Employee.id_employee = @id_employee)"
            UpdateCommand="UPDATE [Employee] SET [fname] = @fname, [lname] = @lname, [id_origin] = @id_origin, [life_support] = @life_support WHERE [id_employee] = @id_employee">
            <DeleteParameters>
                <asp:Parameter Name="id_employee" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="fname" Type="String" />
                <asp:Parameter Name="lname" Type="String" />
                <asp:ControlParameter ControlID="ddlOrigin" DefaultValue="0" Name="id_origin" PropertyName="SelectedValue" />
                <asp:Parameter Name="life_support" Type="Int32" />
                <asp:Parameter Name="id_employee" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="id_employee" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="fname" Type="String" />
                <asp:Parameter Name="lname" Type="String" />
                <asp:Parameter Name="id_origin" Type="Int32" />
                <asp:Parameter Name="life_support" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:IraqEmployeeRosterConnectionStri ng %>"
            SelectCommand="SELECT [id_origin], [origin] FROM [Origin]"></asp:SqlDataSource>
    </form>
</body>
</html>






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to view picture by using form view? mysecondlove ASP.NET 2.0 Basics 1 April 8th, 2008 07:17 AM
Form View in User Control shoakat ASP.NET 2.0 Professional 0 June 20th, 2007 07:29 AM
problems with multiple parameters and datagrid gobotsoup General .NET 0 February 16th, 2007 05:08 PM
Form view control, Authorized edit only nuttylife2 ASP.NET 2.0 Professional 0 July 10th, 2006 07:57 PM
Pivot Chart View Problems wall_of_jericho Access 1 July 27th, 2005 11:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.