当前位置: 代码迷 >> ASP.NET >> 在formview中三个dropdownlist联动的.而且小弟我还要将DropDownlist 与SqlDataSource中的字段绑定.联动现在不行了.也不能在第二次刷新页面了
  详细解决方案

在formview中三个dropdownlist联动的.而且小弟我还要将DropDownlist 与SqlDataSource中的字段绑定.联动现在不行了.也不能在第二次刷新页面了

热度:9065   发布时间:2013-02-25 00:00:00.0
在formview中三个dropdownlist联动的.而且我还要将DropDownlist 与SqlDataSource中的字段绑定.联动现在不行了.也不能在第二次刷新页面了.
<asp:FormView ID="frmvProsPect" runat="server" DefaultMode="Insert" DataSourceID="sqlContract" OnItemInserting="frmvProsPect_ItemInserting" >
  <EditItemTemplate>
   
  <di>
  <div>Prospect&nbsp; Information</div>
  <div></div>
  <div>Prospect Form</div>
  <table style=" width:800px;">
  <tr>
  <td>BA</td>
  <td>
  <asp:DropDownList ID="ddlBA" runat="server" AutoPostBack="True" DataTextField="BAName" DataValueField="BAName" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlBA_SelectedIndexChanged" CssClass="dropdownlist" DataSourceID="sqlBA" SelectedValue='<%# Bind("BA") %>'>
  <asp:ListItem>Please Select BA...</asp:ListItem>
  </asp:DropDownList>
  </td>
  <td>Region</td>
  <td>
   
  <asp:DropDownList ID="ddlRegion" runat="server" AutoPostBack="True" DataTextField="RegionName" DataValueField="ID" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlRegion_SelectedIndexChanged" CssClass="dropdownlist" DataSourceID="sqlRegion">
  <asp:ListItem Selected="True">Please Select Region...</asp:ListItem>
  </asp:DropDownList>
  </td>
  <td style="height: 23px">
  Area</td>
   
   
  <td>
  <asp:DropDownList ID="ddlProvince" runat="server" DataTextField="Province" DataValueField="Province" AppendDataBoundItems="True" CssClass="dropdownlist" DataSourceID="sqlProvince" SelectedValue='<%# Bind("Province") %>'>
  <asp:ListItem>Please Select Area...</asp:ListItem>
  </asp:DropDownList>
  </td>
  </tr>
  </table>
  <div>Distributor Information</div>
  <table style=" width:800px;">
  <tr>
  <td>
  Distributor Chinese Name</td>
  <td>
  <asp:TextBox ID="txtDistributorCN" runat="server" CssClass="textbox" Text='<%# Bind("DistributeCn") %>'></asp:TextBox></td>
   
  <td>
  Distributor Code
  </td>
  <td align="left">
   
  <asp:TextBox ID="txtDistributorCode" runat="server" CssClass="textbox" Text='<%# Bind("DistributeCode") %>'></asp:TextBox></td>
  </tr>
   
  <tr>
  <td >
  Distributor English Name
  </td>
  <td s>
  <asp:TextBox ID="txtDistributorEN" runat="server" CssClass="textbox" Text='<%# Bind("DistributeEn") %>'></asp:TextBox></td>
  <td>
  </td>
  <td>
  </td>
  </tr>
  </table>
  <table>
   
  <tr>
  <td>
  Account Entry Type</td>
  <td>
  <asp:DropDownList ID="ddlAccountEntryType" runat="server" CssClass="dropdownlist">
  <asp:ListItem Selected="True">Please Select...</asp:ListItem>
  <asp:ListItem>Existing RD Cust</asp:ListItem>
  </asp:DropDownList></td>
  <td>
  Competitor Instruments</td>
  <td>
  <asp:DropDownList ID="ddlCompetitor_Instruments" runat="server" DataSourceID="sqlCompInstrument" DataTextField="InstrumentName" DataValueField="InstrumentName" EnableViewState="False" AppendDataBoundItems="True" CssClass="dropdownlist" Width="160px">
  <asp:ListItem Selected="True">Please Select...</asp:ListItem>
  </asp:DropDownList></td>
  </tr>
  </table>
  <div>Instrument Information</div>
  <table>
  <tr>
  <td>
  Instrument Quantity</td>
  <td align="left">
   
  <asp:TextBox ID="txtOrder_Qty" runat="server" CssClass="textbox" Text='<%# Bind("DeliveryQty") %>'></asp:TextBox>
  </td>
  </tr>
   
  </table>
  <table style="width:800px">
  <tr>
  <td>Contract Type</td>
  <td>
  <asp:DropDownList ID="ddlContractType" runat="server" CssClass="dropdownlist" SelectedValue='<%# Bind("ContractType") %>'>
  <asp:ListItem Value="IPA">Placed</asp:ListItem>
  <asp:ListItem Value="DFC">Duty Free</asp:ListItem>
  <asp:ListItem Value="NormalSO">Sales</asp:ListItem>
  <asp:ListItem>Hybrid</asp:ListItem>
  </asp:DropDownList>
  </td>
  </tr>  
  <tr>
  <td>
  Instrument/System</td>
  <td>
  <asp:DropDownList ID="dlInstrument_Type" runat="server" AutoPostBack="True" DataSourceID="sqldsInstrument" DataTextField="InstrumentName" DataValueField="InstrumentCode" OnSelectedIndexChanged="dlInstrument_Type_SelectedIndexChanged" CssClass="dropdownlist">
  <asp:ListItem>Please Select...</asp:ListItem>
  </asp:DropDownList>
  </td>
  <td>
  <asp:Label ID="lblExtension" runat="server" Text="Existing Instrument" Visible="False" Width="113px"></asp:Label></td>
  <td >
  <asp:DropDownList ID="ddlExtensionList" runat="server" Visible="False" CssClass="dropdownlist" >
  </asp:DropDownList><asp:Label ID="lblMessage" runat="server" Text="No Existing Instrument"
  Visible="False"></asp:Label></td>
  </tr>
  </table>
   
   
  </EditItemTemplate>
  </asp:FormView>
   
 

------解决方案--------------------------------------------------------
又想绑定,又要联动,那是不可能地。取消绑定,然后处理formview_iteminserting(updating)事件给相应的列赋值。
  相关解决方案