标记在VS 2008中被删除

时间:2012-08-23 18:34:04

标签: asp.net visual-studio-2008

我正在使用母版页,更新面板,AJAX Tab容器以及modalpopup扩展程序和其他AJAX验证控件。对于Termination Reaon而言大胆的界限存在问题。我需要<asp:ListItem Text="Select Contract Termination Reason.." Value=""></asp:ListItem>来控制错误:

  

'ddlContractTerminationReason'有一个SelectedValue无效,因为它在项目列表中不存在“

它可以正常运行,但是在尝试对应用程序进行其他一些更改时,它突然开始被删除。如果我在单击“保存”后再尝试再次键入,则会删除并保存文件。我的网络管理员为我重新安装了一切,假设某些病毒问题,但看起来像其他东西导致了这一点。对此的任何帮助都非常感激。

<tr> 
  <td> 
    <asp:DropDownList ID="ddlContractTerminationReason" runat="server" AppendDataBoundItems="True" CausesValidation="True" CssClass="dropdown extralong" DataSourceID="dsTerminationReason" DataTextField="ReasonDescription" DataValueField="TerminationReasonID">
      <asp:ListItem Text="Select Contract Termination Reason.."></asp:ListItem>            
    </asp:DropDownList> 
    <asp:CustomValidator ID="cusValTerminationReason" runat="server" ClientValidationFunction="RequireTerminationReason" ControlToValidate="ddlContractTerminationReason" ErrorMessage="Please enter Termination Reason OR Other Resson, if the Contractor is Terminated!" OnServerValidate="ServerValidateTerminationDate" SetFocusOnError="True" Text="*" ValidateEmptyText="True" ValidationGroup="ContrMasterGroup"></asp:CustomValidator> 
    <asp:SqlDataSource ID="dsTerminationReason" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>" SelectCommand="SELECT [TerminationReasonID], [ReasonDescription] FROM [TerminationReasons] ORDER BY [ReasonDescription]"> </asp:SqlDataSource>
  </td>
  <td class="rightalign">
    <asp:Label ID="lblOtherContractTerminationReason" runat="server" CssClass="lbl" Text="if Others, Explain:"></asp:Label>
  </td>
  <td>
   <asp:TextBox ID="txtOtherContractTerminationReason" runat="server" CssClass="long" TextMode="MultiLine"></asp:TextBox> 
  </td>
  <td> </td>
</tr>

1 个答案:

答案 0 :(得分:0)

在DataBind执行此代码后

ddlContractTerminationReason.DataBind();
ddlContractTerminationReason.Items.Add("Select Contract Termination Reason..");