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>
|