Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Issue with Dynamic Dependent Drop Down Menu (http://www.velocityreviews.com/forums/t587127-issue-with-dynamic-dependent-drop-down-menu.html)

john_mcmahon@gap.com 01-25-2008 06:26 AM

Issue with Dynamic Dependent Drop Down Menu
 
I'm having issues dynamically populating a second drop down menu
that's dependent upon a selection in the first drop down menu. When I
select an option from the first menu, the page posts back and doesn't
recognize the "ddlPlantTypeID_SelectedIndexChanged" function from the
onSelectedIndexChanged property of the first menu. I've even inserted
a breakpoint within the function in the code behind to no avail. Why
is the "ddlPlantTypeID_SelectedIndexChanged" function not being
invoked? Where am I going wrong? Is it my code or a missing
configuration?

Thanks,
John


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~

My web page code is:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="
plantgrid.ascx.cs" Inherits="FPSweb.usercontrols.plantgrid" %>
<table width="593" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellpadding="2"
cellspacing="2">
<tr>
<td width="54">Plant ID:</td>
<td width="62"><asp:TextBox ID="txtPlantID"
runat="server" Width="50"></asp:TextBox></td>
<td width="42">Status:</td>
<td width="121"><asp:DropDownList ID="ddlPlantStatus"
runat="server" Width="110"></asp:DropDownList></td>
<td><asp:Button ID="btnSearch" runat="server"
OnClick="btnSearch_Click" Text="Search" /></td>
</tr>
</table></td>
</tr>
<tr><td><hr /></td></tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="2"
cellspacing="2">
<tr>
<td width="129">Select the type of plant:</td>
<td><asp:DropDownList ID="ddlPlantTypeID"
runat="server" Width="326" AutoPostBack="true"
OnSelectedIndexChanged="ddlPlantTypeID_SelectedInd exChanged"></
asp:DropDownList></td>
<td width="95"> </td>
</tr>
<tr>
<td>Select the variety of plant:</td>
<td><asp:DropDownList ID="ddlVarietyID"
runat="server" Width="326"></asp:DropDownList></td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr><td><hr /></td></tr>
</table>
<br />
<asp:Label ID="lblmessage" runat="server" Text="" Visible="false" />
<asp:ObjectDataSource ID="ObjectDataSourcePlantSearch" runat="server"
SelectMethod="SearchPlant"
TypeName="BusinessLayer.Plant">
<SelectParameters>
<asp:ControlParameter ControlID="ddlPlantTypeID"
DefaultValue="" Name="m_planttypeid"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlVarietyID" DefaultValue=""
Name="m_varietyid"
PropertyName="SelectedValue" Type="String" />
<asp:QueryStringParameter DefaultValue="" Name="m_groupid"
QueryStringField="groupid"
Type="String" />
<asp:ControlParameter ControlID="ddlPlantStatus"
DefaultValue="" Name="m_statuscode"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<table width="589" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="46" style="border-left:1px solid #D6D3CE;"
class="gridViewHeader">Group Number</td>
<td width="33" class="gridViewHeader">Plant</td>
<td width="62" class="gridViewHeader">Accession</td>
<td width="133" class="gridViewHeader">Location</td>
<td width="95" class="gridViewHeader">Source</td>
<td width="60" class="gridViewHeader">Plant<br /> Date</td>
<td width="77" class="gridViewHeader">Variety<br /> Name</td>
<td style="border-right:1px solid #D6D3CE; text-align:left;"
class="gridViewHeader">Status</td>
</tr>
</table>
<div id="gridscroll" class="scroll">
<asp:GridView ID="dgPlants" runat="server" Width="589"
BorderStyle="solid" BorderColor="#D6D3CE" ShowHeader="False"
AllowSorting="True" DataSourceID="ObjectDataSourcePlantSearch"
AutoGenerateColumns="False" >
<AlternatingRowStyle BackColor="Gainsboro" />
<Columns>
<asp:HyperLinkField HeaderText="Group Number"
SortExpression="GroupID" DataTextField="GroupID"
DataNavigateUrlFormatString="~/group.aspx?groupid={0}"
DataNavigateUrlFields="GroupID" ItemStyle-Width="48" />
<asp:HyperLinkField HeaderText="Plant"
SortExpression="PlantID" DataTextField="PlantID"
DataNavigateUrlFormatString="~/plant.aspx?plantid={0}"
DataNavigateUrlFields="PlantID" ItemStyle-Width="35" />
<asp:BoundField HeaderText="Accession"
DataField="AccessionDescription" SortExpression="AccessionDescription"
ItemStyle-Width="64" />
<asp:BoundField ItemStyle-Wrap="false" HeaderText="Location"
DataField="Location" SortExpression="Location" ItemStyle-Width="135" /
>

<asp:BoundField HeaderText="Source"
DataField="GroupPublicSource" ItemStyle-Width="97" />
<asp:BoundField HeaderText="Plant Date" DataField="PlantDate"
SortExpression="PlantDate" ItemStyle-Width="62" />
<asp:BoundField HeaderText="Variety Name"
DataField="VarietyDescription" SortExpression="VarietyDescription"
ItemStyle-Width="79" />
<asp:BoundField HeaderText="Status" DataField="RemoveStatus" /
>

</Columns>
<EmptyDataTemplate>
<div style="width:585px; font-weight:bold; text-
align:center;">No records found</div>
</EmptyDataTemplate>
</asp:GridView>
</div>


My code behind is:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BusinessLayer;
using LT;

namespace FPSweb.usercontrols
{
public partial class plantgrid : BaseUserControl
{
protected int plantid;
protected string plantstatuscode = "";
protected int varietyid;
protected int planttypeid;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
plantid = Utils.GetQSParamAsInt("plantid");
// plantstatuscode =
Utils.GetQSParamAsString("plantstatuscode") == null ? "" :
Utils.StripHTML(Utils.GetQSParamAsString("plantsta tuscode"));
plantstatuscode = "NRM";
varietyid = Utils.GetQSParamAsInt("varietyid");
planttypeid = Utils.GetQSParamAsInt("planttypeid");
BindControls();
}
}
protected void BindControls()
{
string err = "";
txtPlantID.Text = plantid.ToString();
Common.PopulateStatusDropDown(this.ddlPlantStatus, true,
plantstatuscode.ToString(), "plant");
PopulateDropDown(this.ddlPlantTypeID, Common.GetPlantTypes
(0, out err), "plantTypeDescription", "plantTypeID", true,
planttypeid.ToString());
this.ddlVarietyID.Items.Insert(0, new ListItem("Select
one", ""));
this.ddlVarietyID.Enabled = false;
//PopulateDropDown(this.ddlVarietyID, null,
"varietyDescription", "varietyID", true, varietyid.ToString());
//PopulateDropDown(this.ddlGroupID ,
Group.GetGroup(groupid.ToString()), "groupid", "groupid", true,
groupid.ToString());
}

protected void btnSearch_Click(object sender, EventArgs e)
{
string qrystr = "";
plantid = Utils.CInt(txtPlantID.Text);
plantstatuscode = ddlPlantStatus.SelectedValue.ToString();
varietyid = Utils.CInt(ddlVarietyID.SelectedValue);
planttypeid = Utils.CInt(ddlPlantTypeID.SelectedValue);

qrystr += (Utils.IsEmpty(plantid)) ? "" :
(Utils.IsEmpty(qrystr)) ? "?plantid=" + plantid : "&plantid=" +
plantid;
qrystr += (Utils.IsEmpty(plantstatuscode)) ? "" :
(Utils.IsEmpty(qrystr)) ? "?plantstatuscode=" + plantstatuscode :
"&plantstatuscode=" + plantstatuscode;
qrystr += ( Utils.IsEmpty(varietyid)) ? "" :
(Utils.IsEmpty(qrystr)) ? "?varietyid=" + varietyid : "&varietyid=" +
varietyid;
qrystr += (Utils.IsEmpty(planttypeid)) ? "" :
(Utils.IsEmpty (qrystr)) ? "?planttypeid=" + planttypeid :
"&planttypeid=" + planttypeid;

if (!Utils.IsEmpty(plantid))
{
Response.Redirect("~/plant.aspx" + qrystr);
}
}

protected void ddlPlantTypeID_SelectedIndexChanged(object
sender, EventArgs e)
{
LoadDropDown2Data();
}

private void LoadDropDown2Data()
{
string err = "";
// PopulateDropDown(this.ddlVarietyID,
Common.GetVarieties(0, this.ddlPlantTypeID.SelectedIndex, out err),
"varietyDescription", "varietyID", true, varietyid.ToString());
this.ddlVarietyID.Items.Insert(0, new ListItem("No", ""));
this.ddlVarietyID.Enabled = true;
}
}
}


All times are GMT. The time now is 05:41 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.