2

このチュートリアルを使用して、リピーターを使用してプロジェクトのページに名前のリストを表示しました。

だから私は動的データを使用しており、私の aspx.cs ページには次のものがあります。

List<string> subContractors = new List<string>();

Context db = new Context();
subContractors = (from SUBContractors in db.BOQ_SubContractors
                  where SUBContractors.Bill_Of_Quantity_id == this.boqId
                  select SUBContractors.Sub_Contractor.Company_Name).ToList();

repeaterShowSubContractorName.DataSource = subContractors; repeaterShowSubContractorName.DataBind();

私のaspxで:

<asp:Repeater ID="repeaterShowSubContractorName" runat="server" OnItemDataBound="subContractors_ItemDataBound">
  <HeaderTemplate>
    <table>
      <tr>
        <th>
          <asp:Label ID="SubConName" Text="SubContractor Name" runat="server"></asp:Label>
        </th>
      </tr>
    </table>
  </HeaderTemplate>
  <ItemTemplate>
    <tr>
      <td>
        <asp:Label ID="SubCon" Text='<%# Eval("subContractors") %>' runat="server"></asp:Label>
       </td>
     </tr>
   </ItemTemplate>
 </asp:Repeater>

エラーはから来ていOnItemDataBound="subContractors_ItemDataBound"ます。

これを何に、またはどこにリンクしますか? subContractors_ItemDataBound現時点ではありません。

4

2 に答える 2

7

OnItemDataBound="subContractors_ItemDataBound"aspx ページから削除するだけです

eventsubContractors_ItemDataBoundを処理するメソッドが .cs ファイルにないため、このエラーが発生し ました。イベントを処理するか、単に削除する必要があります。OnItemDataBoundOnItemDataBoundOnItemDataBound="subContractors_ItemDataBound"

使用する文字列のリストをバインドする編集:

<asp:Label ID="SubCon" Text='<%# Container.DataItem %>' runat="server"></asp:Label>

于 2013-01-30T13:33:25.383 に答える
2

ページの読み込み時 (またはデータを読み込みたい場所) でこれを実行して、データをリピーターにリンクします。

    repeaterShowSubContractorName.DataSource = subContractors;
    repeaterShowSubContractorName.DataBind();

そして取り除く

    OnItemDataBound="subContractors_ItemDataBound"
于 2013-01-30T13:34:43.007 に答える