2012-05-03 12 views
0

私は以下のフォームビューを持っています。情報を表示できるようにしたいと思っています。もし誰かが変更を加えたら、update.Iをクリックしてこの情報を更新しなければなりません。私はfrm1がeditmodeを期待していると言って例外を残している。可能な場合は事前にFormviewでEditItemTemplateとItemTemplateを同時に使用する方法はありますか?

おかげ

<<asp:Formview D="FormView1" runat="server" DataSourceID="SqlDesc" ID="frm1"> 
    <ItemTemplate> 
     <table> 
     <tr> 
      <td> 
       Description:<br /> 
      </td> 
      <td style=""> 
       <asp:TextBox ID="DescTbox" runat="server" Width="450px" TextMode="MultiLine" Text='<%# Bind("Description") %>' Enabled="True" Rows="4"></asp:TextBox>     
      </td>     
     </tr> 
     <tr> 
     <td></td> 
     <td> 
      <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update"> </asp:Button> 
     </td>     
     </tr> 
    </table> 
    </ItemTemplate> 
    <EditItemTemplate> 
    <table> 
     <tr> 
      <td> 
       Description:<br /> 
      </td> 
      <td style=""> 
       <asp:TextBox ID="DescTbox" runat="server" Width="450px" TextMode="MultiLine" Text='<%# Bind("Description") %>' Enabled="True" Rows="4"></asp:TextBox>     
      </td>     
     </tr> 
     <tr> 
     <td></td> 
     <td> 
      <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update"> </asp:Button> 
     </td>     
     </tr> 
    </table> 

    </EditItemTemplate> 
    </asp:Formview> 

答えて

1

はあなたの<Itemtemplate>は更新のみ<EditItemTemplate>で利用可能で、データの読み込み専用のビューを提供する必要があります。テーブル上にEditRowIndexを設定して、行を編集できるように行を編集モードにする必要があります。

+1

申し訳ありませんが、あなたは、任意の例を与えることができますか? – CPM

0
私が編集として DefaultModeを追加し、 ItemTemplate

<asp:Formview ID="FormView1" runat="server" DefaultMode="Edit" > 
     <EditItemTemplate> ... 
     </EditItemTemplate> <asp:Formview> 

の代わりにEditItemTemplateを使用していた

おかげ

関連する問題