zoukankan      html  css  js  c++  java
  • ObjectDatasourse 的绑定及显示

    LinqDatasourse    SQldatasourse    都是<%# Eval(“ 列名”);%>单向绑定数据;

    objectDatasourse   不同。   <%#Bind(“列名”);%> 这是双向绑定 。

    创建objectdatasourse   ,首先拉进一个objectdatasourse,选择配置数据源,再选择业务对象(就是针对要显示的表,编辑的逻辑关系类,例CarDa其中包括增删改查方法),下一步在定义数据方法  时,选取使用的函数名。

    下面是绑定显示的实现。

            <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AutoGenerateColumns="False">

                <Columns>

                    <asp:TemplateField>

                        <EditItemTemplate>

                            编号:<asp:TextBox ID="TextBox1" Text='<%#Bind("Code") %>' runat="server"></asp:TextBox>

                            <br />

                            姓名:<asp:TextBox ID="TextBox2" Text='<%#Bind("Name") %>' runat="server"></asp:TextBox>

                            <asp:Button ID="Button1" runat="server" CommandName="Update" Text="修改" />

                        </EditItemTemplate>

                        <ItemTemplate>

                            编号:<asp:Label ID="Label1" runat="server" Text='<%#Bind("Code") %>'></asp:Label>

                            姓名:<asp:Label ID="Label2" runat="server" Text='<%#Bind("Name")%>'></asp:Label>

                            <asp:Button ID="Button1" runat="server" CommandName="delete" Text="编辑" />

                        </ItemTemplate>

                    </asp:TemplateField>

                </Columns>

            </asp:GridView>

  • 相关阅读:
    求子数组最大和
    <转>Android APP字体大小,不随系统的字体大小变化而变化的方法
    模块25 pageobject改造【进阶】
    第5阶段直播
    web测试-赠送课程
    模块四 -使用postman发送请求
    模块三 使用tcpdump抓包分析tcp三次握手四次挥手
    模块二 常见接口协议解析
    20200611_19元素操作
    20200609_18八大元素定位
  • 原文地址:https://www.cnblogs.com/huaze/p/4361223.html
Copyright © 2011-2022 走看看