zoukankan      html  css  js  c++  java
  • FormView中EditItemTemplate的注意事项

    html代码
    <asp:FormView ID="bidForm" runat="server" DataKeyNames="BidId" OnItemInserted="form_ItemInserted" OnItemUpdated="form_ItemUpdated" OnItemDeleted="form_ItemDeleted"
               DataSourceID="bidDS">
                <HeaderTemplate><h1> Bid Details </h1></HeaderTemplate>
           
            <ItemTemplate>
            <table id="Table1" class="table" cellspacing="0">
            <tr>
                <th>Currency:</th>
                <td><%# Eval("Currency.Code") %></td>
                <td><asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" /></td>
            </tr>
            </table>            
           </ItemTemplate>
           <EditItemTemplate>
            <table id="Table2" class="table" cellspacing="0">
            <tr>
                <th>Currency:</th>
                <td><asp:DropDownList ID="DropCurrency" runat="server" SelectedValue='<%# Bind("CurrencyId") %>' DataValueField="CurrencyId" DataTextField="Code" DataSourceID="currencyDS">
    </asp:DropDownList></td>
                <td><asp:LinkButton ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
                  <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" /></td>
            </tr>
            </table>            
           </EditItemTemplate>
                            
        </asp:FormView>


    <asp:LinqDataSource ID="bidDS" runat="server"
            ContextTypeName="FactBaserDB" EnableInsert="true"
            EnableUpdate="True" TableName="Bids"
            AutoGenerateWhereClause="True">      
         <WhereParameters>
             <asp:Parameter Name="BidId" DefaultValue="2" Type="Int32" />
         </WhereParameters>      
        </asp:LinqDataSource>


    <asp:LinqDataSource ID="currencyDS" runat="server"
            ContextTypeName="FactBaserDB" Select="new (CurrencyId, Code)"
            TableName="Currencies" ></asp:LinqDataSource>

    注意
    上面的table2控件如果写runat="server"后.则数据不会读取EditItemTemplate的里控件的值,尽管你用了<%# Bind("CurrencyId") %>,
    InsertItemTemplate中也是一样.
    所以在FormViewInsertItemTemplateEditItemTemplate里如果用到了table(里面有要获取的值时),此table不能设置runat="server".
  • 相关阅读:
    Redission 中 RPermitExpirableSemaphore 用法
    Linux查询CPU核数
    Http超时时间之SocketTimeout
    In Theano, how to do Reverse-MaxPooling in the Convolutional MaxPooling Auto-Encoder
    如何让Ubuntu中virtualbox虚拟机用上USB设备
    Deep Learning Stuffs(持续更新中……)
    实例描述如何用python组件ctypes调用c的dll中的函数
    放弃MATLAB!简述winpython为什么比MATLAB更方便
    虚拟机Ubuntu10.04无法显示windows中文目录和文件
    W: GPG 错误
  • 原文地址:https://www.cnblogs.com/qfb620/p/1214673.html
Copyright © 2011-2022 走看看