Hey Sam,
Here's the code from the child page:
Code:
<%@ Page Language="C#" MasterPageFile="~/CEMMaster.master" AutoEventWireup="true" CodeFile="CEMDevMgmnt.aspx.cs" Inherits="CEMDevMgmnt" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/CEMMaster.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:DropDownList ID="cboDevices" runat="server" AutoPostBack="True" DataSourceID="CEMDevices"
DataTextField="ANALYZER_NAME" DataValueField="ANALYZER_NAME">
</asp:DropDownList><br />
<br />
<asp:FormView ID="FormView1" runat="server" DefaultMode="ReadOnly" DataKeyNames="ANALYZER_NAME" DataSourceID="CEMDevData">
...
<ItemTemplate>
<table style="width:450px">
<tr>
<td><b>Device Name:</b></td><td>
<asp:Label ID="ANALYZER_NAMELabel" runat="server" Text='<%# Bind("ANALYZER_NAME") %>'></asp:Label>
</td>
<td><b>Sort Order:</b></td><td>
<asp:Label ID="ORDER_NUMLabel" runat="server" Text='<%# Bind("ORDER_NUM") %>'></asp:Label>
</td>
</tr>
<tr>
<td><b>Description:</b></td><td colspan="3">
<asp:Label ID="DESCRIPTORLabel" runat="server" Text='<%# Bind("DESCRIPTOR") %>'></asp:Label>
</td>
</tr>
...
<asp:SqlDataSource ID="CEMDevices" runat="server" ConnectionString="<%$ ConnectionStrings:TOL_CEM_Connect %>"
SelectCommand="SELECT DISTINCT [ANALYZER_NAME] FROM [appToledoCEM].[ANALYZERS]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="CEMDevData" runat="server" ConnectionString="<%$ ConnectionStrings:TOL_CEM_Connect %>">
<SelectParameters>
<asp:ControlParameter ControlID="cboDevices" Name="ANALYZER_NAME2" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<InsertParameters>
<asp:ControlParameter ControlID="ANALYZER_NAMETextBox" Name="AnalyzerName" Type="string" PropertyName="Text" />
<asp:ControlParameter ControlID="DESCRIPTORTextBox" Name="Descriptor" Type="string" PropertyName="Text" />
<asp:ControlParameter ControlID="LOCATIONTextBox" Name="Location" Type="string" PropertyName="Text" />
<asp:ControlParameter ControlID="ORDER_NUMTextBox" Name="OrderNum" Type="Int32" PropertyName="Text" />
<asp:ControlParameter ControlID="TS_ADDTextBox" Name="AddUse" Type="DateTime" PropertyName="Text" />
<asp:ControlParameter ControlID="TS_REMOVETextBox" Name="RemUse" Type="DateTime" PropertyName="Text" />
<asp:SessionParameter Name="Adder" SessionField="UserID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
The code behind:
Code:
public partial class CEMDevMgmnt : System.Web.UI.Page
{
...
void cboDevices_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
Master.WriteLog(string.Format("Selected Device {0}", ddl.Text));
Parameter pm = (Parameter)CEMDevData.SelectParameters["ANALYZER_NAME2"];
Master.WriteLog(string.Format("{0} = {1}", pm.Name, pm.DefaultValue));
CEMDevData.SelectParameters["ANALYZER_NAME2"].DefaultValue = ddl.Text.Trim();
this.CEMDevData.DataBind();
FormView1.DataBind();
}
...
The log file shows the correct selected device! but FormView1 indicates no records returned. Bear in mind that FormView1 does show data when it opens for the initially selected device. So I know the binding to FormView1's datasource works. But when I select a different device with the dropdownlist I get no rows returned! If I re-select the initially selected device, I get no rows returned.
What you don't know can hurt you!