2017-01-20 8 views
0

My FormViewはDataBindを持たない。私は何のエラーもなく、すべての要素が正しく見つけられます。コードをステップ実行すると、すべてが期待どおりに動作するように見えます。選択パラメータが設定され、FormViewがDataBoundです。コードビハインドのDatabind()は決してデータベースに到達しません

しかし、データは返されず、データベースログでは、DataBoundとなるプロシージャには決して触れないことが示されます。背後に

更新パネル

<asp:updatepanel ID="upnlMixingTankInfo" runat="server"> 
<ContentTemplate> 
<asp:formview id="fvMixingTankInfo" runat="server" datasourceid="SqlDataSourceMixingTankInfo"> 
    <ItemTemplate> 
     <asp:label runat="server">Vessel Capacity:</asp:label> 
     <asp:TextBox ID="vesselCapacity" runat="server" class="form-control" Text='<%# Bind("fldVesselCapacity")%>'></asp:TextBox> 
    </ItemTemplate> 
    </asp:formview> 
</ContentTemplate> 

コード:

SourceDropDownList = sender 
    upnlMixingTankInfo = CType(SourceDropDownList.Parent.FindControl("upnlMixingTankInfo"), UpdatePanel) 
     fvTankInfo = CTYPE(upnlMixingTankInfo.FindControl("fvMixingTankInfo"), FormView) 
     If Not IsNothing(SourceDropDownList.SelectedValue) Then 
      SqlDataSourceMixingTankInfo.SelectParameters.Add("TankName", DropDownListEquipmentList.SelectedValue) 
     End If 
     fvTankInfo.Databind() 

SQLDATSOURCE:

  <asp:SqlDataSource ID="SqlDataSourceMixingTankInfo" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ZMConnectionString %>" 
    SelectCommand="EXEC stpWebGetMixTankCapacity @TankName" > 
    <SelectParameters> 
     <asp:Parameter Name="TankName" defaultvalue=""/> 
    </SelectParameters> 

+0

SqlDataSourceの代わりに 'SelectCommandType =" StoredProcedure "をテキストコマンドタイプを使用して設定しましたか?また、 '' –

+0

を使用して、ドロップダウンリストの値を直接プロシージャにバインドすることができます。 –

答えて

2

SqlDataSourceにいくつかの変更が加えられました。自分のspを使ってテストしましたが、あなたの使い方に合わせて修正しました。

のUpdatePanel & FormViewコントロール

<asp:UpdatePanel ID="upnlMixingTankInfo" runat="server"> 
    <ContentTemplate> 
     <asp:FormView ID="fvMixingTankInfo" runat="server" DataSourceID="SqlDataSource1"> 
      <ItemTemplate> 
       <asp:Label ID="Label1" runat="server">Vessel Capacity:</asp:Label> 
       <asp:TextBox ID="vesselCapacity" runat="server" class="form-control" Text='<%# Bind("Name")%>'></asp:TextBox> 
      </ItemTemplate> 
     </asp:FormView> 
    </ContentTemplate> 
</asp:UpdatePanel> 

コードは背後に、私はあなたが好きな場所あなたは同じコードを使用することができ、負荷にテストしてみました。

protected void Page_Load(object sender, EventArgs e) 
    { 
     SqlDataSource1.SelectParameters.Add("Id", "10"); 
    } 

変更とSqlDataSourceコントロール:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    SelectCommand="GetImages" SelectCommandType="StoredProcedure"> 
</asp:SqlDataSource> 

それは私がここに提出する前にテストしてみた、完璧に動作します。

関連する問題