empyrean
11-30-2009, 11:42 PM
i tried to some extent in solving this. looks like everything is good but i dont know why it is not taking it as parameter?? i am getting the error ("ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@Crop_ID'.")
Please check my code and suggest me something as my proj depends on linking the dropdowns and populating the list box at the end.. i am new to web development and unable to find the error...
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Report_csharp.aspx.cs" Inherits="Report_csharp" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="lb_Crop" runat="server" Text="Crop Name:"></asp:Label>
<asp:DropDownList ID="ddl_Crop" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
OnSelectedIndexChanged="ddl_Crop_SelectedIndexChanged"
DataSourceID="SDS_Crop" DataTextField="CropName" DataValueField="Crop_ID">
</asp:DropDownList>
<asp:Label ID="lb_Project" runat="server" Text="Project Name:"></asp:Label>
<asp:DropDownList ID="ddl_proj" runat="server" AutoPostBack="True"
DataSourceID="SDS_Proj" DataTextField="Project_ID"
DataValueField="Crop_ID">
</asp:DropDownList>
<asp:SqlDataSource ID="SDS_Proj" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanOfWorkConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:PlanOfWorkConnectionString1.ProviderName %>"
SelectCommand="SELECT [Crop_ID], [Project_ID] FROM [Project_Table]WHERE ([Crop_ID]=@Crop_ID)">
<SelectParameters>
<asp:ControlParameter ControlID = "ddl_Crop" Name = "Crop_ID" PropertyName = "SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_Crop" runat="server" ConnectionString="<%$ ConnectionStrings:PlanOfWorkConnectionString1 %>"
SelectCommand="SELECT [CropName], [Crop_ID] FROM [Crop_Table]"
ProviderName="<%$ ConnectionStrings:PlanOfWorkConnectionString1.ProviderName %>"></asp:SqlDataSource>
</asp:Content>
Please check my code and suggest me something as my proj depends on linking the dropdowns and populating the list box at the end.. i am new to web development and unable to find the error...
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Report_csharp.aspx.cs" Inherits="Report_csharp" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="lb_Crop" runat="server" Text="Crop Name:"></asp:Label>
<asp:DropDownList ID="ddl_Crop" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
OnSelectedIndexChanged="ddl_Crop_SelectedIndexChanged"
DataSourceID="SDS_Crop" DataTextField="CropName" DataValueField="Crop_ID">
</asp:DropDownList>
<asp:Label ID="lb_Project" runat="server" Text="Project Name:"></asp:Label>
<asp:DropDownList ID="ddl_proj" runat="server" AutoPostBack="True"
DataSourceID="SDS_Proj" DataTextField="Project_ID"
DataValueField="Crop_ID">
</asp:DropDownList>
<asp:SqlDataSource ID="SDS_Proj" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanOfWorkConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:PlanOfWorkConnectionString1.ProviderName %>"
SelectCommand="SELECT [Crop_ID], [Project_ID] FROM [Project_Table]WHERE ([Crop_ID]=@Crop_ID)">
<SelectParameters>
<asp:ControlParameter ControlID = "ddl_Crop" Name = "Crop_ID" PropertyName = "SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_Crop" runat="server" ConnectionString="<%$ ConnectionStrings:PlanOfWorkConnectionString1 %>"
SelectCommand="SELECT [CropName], [Crop_ID] FROM [Crop_Table]"
ProviderName="<%$ ConnectionStrings:PlanOfWorkConnectionString1.ProviderName %>"></asp:SqlDataSource>
</asp:Content>