asp.net ListView控件的简单实用和配置
1 web窗体界面代码
ItemType:控件要绑定的实体模型
SelectMethod:控件获取实体集合的后台方法
DataKeyNames:实体的主键
UpdateProduct:设置跟新的方法
DeleteMethod:删除实体的方法
InsertProduct:插入实体的方法
InsertItemPosition:新插入实体的位置
EnableViewState:禁用视图状态
这些方法都可以在自定义在web窗体的代码后置中
<asp:ListView runat="server" ItemType="SportsStore.Models.Product" SelectMethod="GetProducts"
DataKeyNames="ProductID" UpdateMethod="UpdateProduct" DeleteMethod="DeleteProduct"
InsertMethod="InsertProduct" InsertItemPosition="LastItem" EnableViewState="false"> <LayoutTemplate>
<div class="outerContainer">
<table id="productsTable">
<tr>
<th>Name</th>
<th>Description</th>
<th>Category</th>
<th>Price</th>
</tr>
<tr runat="server" id="itemPlaceholder">
</tr>
</table>
</div>
</LayoutTemplate> <ItemTemplate>
<tr>
<td><%#Item.Name %></td>
<td class="description">
<span>
<%#Item.Description %>
</span>
</td>
<td><%#Item.Category %></td>
<td><%#Item.Price.ToString("c") %></td>
<td>
<asp:Button CommandName="Edit" Text="Edit" runat="server" />
<asp:Button CommandName="Delete" Text="Delete" runat="server" />
</td>
</tr>
</ItemTemplate> <EditItemTemplate>
<tr>
<td>
<input name="name" value="<%#Item.Name%>" />
<input type="hidden" name="ProductID" value="<%#Item.ProductID%>" />
</td>
<td>
<input name="description" value="<%#Item.Description %>" />
</td>
<td>
<input name="category" value="<%#Item.Category %>" />
</td>
<td>
<input name="price" value="<%#Item.Price %>" />
</td>
<td>
<asp:Button CommandName="Update" Text="Update" runat="server" />
<asp:Button CommandName="Cancel" Text="Cancel" runat="server" />
</td>
</tr>
</EditItemTemplate> <InsertItemTemplate>
<tr>
<td>
<input name="name" />
<input type="hidden" name="ProductID" value="" />
</td>
<td>
<input name="description" />
</td>
<td>
<input name="category" />
</td>
<td>
<input name="price" />
</td>
<td>
<asp:Button CommandName="Insert" Text="Add" runat="server"/>
</td>
</tr>
</InsertItemTemplate> </asp:ListView>
这个控件包含了几个不同的模板,效果如下:

asp.net ListView控件的简单实用和配置的更多相关文章
- android中ListView控件最简单的用法
创建一个活动,在xml文件中添加一个ListView控件,id定义为list1,并且设置为满屏显示,代码如下: <ListView android:id="@+id/list1&quo ...
- js jsp 时间 日期 控件 插件 简单 实用
js时间控件一般都是找网上的用,这东西平常很少涉及到,一用到找起来却烦死人,不是没用就是太复杂,今天向大家推荐一个简单实用的控件,该控件在不断更新,而且有专门的网站对它进行维护,所以值得一看. 先说它 ...
- ASP.NET Repeater控件实现简单分页
早上,有看MSDN,看到了 PagedDataSource 类 http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.pa ...
- ListView控件(下)简单适配器
(一) 1.效果图 2.activiy_main.xml <?xml version="1.0" encoding="utf-8"?> <Li ...
- EChart 关于图标控件的简单实用
1.下载前段框架并放入项目中去. 2.在js中调用 <!DOCTYPE html> <html lang="en"> <head> <me ...
- ASP.NET数据绑定控件简介
•数据绑定分为数据源和数据绑定控件两部分(①数据绑定控件通过数据源获取和修改数据②数据绑定控件通过数据源隔离数据提供者和数据使用者)数据绑定控件→数据源→数据库•数据源:SqlDataSource(连 ...
- 《ASP.NET1200例》ListView 控件与DataPager控件的结合<二>
ASP.NET使用ListView数据绑定控件和DataPager实现数据分页显示 为什么使用ListView+DataPager的方式实现分页显示? .net提供的诸多数据绑定控件,每一种都有它自己 ...
- 《ASP.NET1200例》ListView 控件与DataPager控件的结合<一>
分页 在前一部分开始时介绍的原 HTML 设计中内含分页和排序,所以根据规范完整实现该网格的任务尚未完成.我们先分页,然后再排序. ListView 控件中的分页通过引入另一个新控件 Data ...
- 《ASP.NET1200例》ListView控件之修改,删除与添加
aspx <body> <form id="form1" runat="server"> <div> <asp:Lis ...
随机推荐
- Android 屏幕适配之dimens适配
Android 屏幕适配之dimens适配 转 https://blog.csdn.net/github_2011/article/details/72636851 在过去多个项目中一直使用 ...
- 连接池中的maxIdle,MaxActive,maxWait参数
连接池中的maxIdle,MaxActive,maxWait参数 线程池 name:表示你的连接池的名称也就是你要访问连接池的地址 auth:是连接池管理权属性,Container表示容器管理 typ ...
- CSS3常用属性及效果汇总
本文转载于<https://blog.csdn.net/lyznice/article/details/54575905> 一.2D效果属性 要使用这些属性,我们需要通过 transfor ...
- OpenStack Nova Release(Rocky to Train)
目录 文章目录 目录 前言 演进方向 Cellv2 更新 Rocky Support disabling a cell Stein Handling a down cell Train Count q ...
- 05-06 Flutter JSON和序列化反序列化、创建模型类转换Json数据、轮播图数据渲染:Flutter创建商品数据模型 、请求Api接口渲染热门商品 推荐商品
Config.dart class Config{ static String domain='http://jd.itying.com/'; } FocusModel.dart class Focu ...
- PAT 甲级 1021 Deepest Root (25 分)(bfs求树高,又可能存在part数part>2的情况)
1021 Deepest Root (25 分) A graph which is connected and acyclic can be considered a tree. The heig ...
- Spring Aop(八)——advisor标签
转发地址:https://www.iteye.com/blog/elim-2396274 8 advisor标签 advisor标签是需要定义在aspect标签里面的,其作用与aspect类似,可以简 ...
- Shell脚本中怎么实现用户切换实现操作
当我们在服务器上面疯狂的进行操作的时候,我们用shell脚本来帮我们来完成一些基本的任务,但是一些命令或者一些操作需要我们不断切换用户来实现的话,在shell脚本就不那么好实现了,那么我们在shell ...
- Linux基础(特基本的那种)知识
(自己的随手笔记,记得有点乱请轻喷) which:查看某个命令的完整路径df -h:查看系统磁盘情况history:查看历史输入的命令 网卡配置路径:vim /etc/sysconfig/networ ...
- 【编程开发】CMake相关注意事项
[编程开发]CMake相关注意事项 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ CMake是一个非常常用的跨平台移植的工具,CMake可用来生成不同平台下 ...