在找到类似问题的同时,我还没有找到答案让我想到的地方。
我有一个ModalPopupExtender,我已经链接到一个填充了Job #s的DropDownList。当我从列表中选择一个作业时,我希望面板出现。但是,如果我第二次单击下拉列表(在选择了一个作业之后),Panel将按预期显示,并填充数据,这不会发生。
以下是aspx中的相关代码:
<Ajax:ModalPopupExtender ID="NonImportedPopupExtender" runat="server"
OkControlID="ImportButton"
TargetControlID="NonImportedDetailDropDownList"
CancelControlID="CancelButton"
OnCancelScript="PopupCancel()"
OnOkScript="NonImportedModalPopupDoUpdate()"
PopupControlID="NonImportedPopupPanel" />
<asp:Panel ID="NonImportedPopupPanel" runat="server" Width="600" Height="350">
<br />
<asp:Label ID="NotImportedLabel" runat="server" Text="NonImported Job Detail:"></asp:Label>
<br />
<asp:Repeater ID="NonImportedDetailRepeater" runat="server"
>
<HeaderTemplate>
<table width="450">
<tr>
<th>TSID</th>
<th>PKey</th>
<th>EID</th>
<th>Name</th>
<th>ST Hrs</th>
<th>OT Hrs</th>
<th>BIT</th>
<th>Vision</th>
<th>Imported</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("TimesheetID") %></td>
<td><%# Eval("PKey") %></td>
<td><%# Eval("Employee") %></td>
<td><%# Eval("Name") %></td>
<td><%# Eval("RegHrs") %></td>
<td><%# Eval("OvtHrs") %></td>
<td><%# Eval("BIT_Directive") %></td>
<td><%# Eval("VisionStatus") %></td>
<td><%# Eval("Completed") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:Button ID="ImportButton" runat="server" Text="Set As Imported" Visible="false" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" Visible="false" />
</asp:Panel>
以下是下拉列表的索引更改:
protected void NonImportedDetailDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string myJob = this.NonImportedDetailDropDownList.SelectedValue.ToString();
NonImportedPopupPanel.Visible = true;
if (myJob != null)
{
SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["InterfaceDev"].ConnectionString);
string myCommandText = "BillingDirectives_ShowNonImportedByJob";
SqlCommand myCommand = new SqlCommand(myCommandText, myConn);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.AddWithValue("@Job", myJob);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(myCommand);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);
DataTable myDataTable = myDataSet.Tables[0];
NonImportedDetailRepeater.DataSource = myDataTable;
NonImportedDetailRepeater.DataBind();
CancelButton.Visible = true;
ImportButton.Visible = true;
}
else
{
WarningLabel.ForeColor = System.Drawing.Color.Red;
WarningLabel.Text = "Cannot determine selected Job #!";
}
}
catch (SqlException ex)
{
WarningLabel.ForeColor = System.Drawing.Color.Red;
WarningLabel.Text = "SQL Error: " + ex.Message.ToString();
}
finally
{
//GridView1.DataBind();
}
}
以下是DDL - Adam的问题:
<div>
<asp:Label ID="NonImportedLabel" runat="server" Text="Show NonImported Detail:"></asp:Label>
<br />
<asp:DropDownList ID="NonImportedDetailDropDownList" runat="server"
Width="140"
ToolTip="Show NonImported Detail by Job"
OnSelectedIndexChanged="NonImportedDetailDropDownList_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
</div>