zoukankan
html css js c++ java
listview 的用法 (asp.net3.5新增控件)
listview控件如图:本实例主要展示了listview控件的ItemCreated事件,ItemUpdating事件,前者主要是发生在databound事件之前改变页面的内容,itemupdating事件只要是用来设置更新数据时的事件。本例结合杨中科老师讲解的dropdownlist和listview控件来展开的,希望能给自己和大家带来启示!!
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; namespace WebApplication3 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { DropDownList ddlist = (DropDownList)ListView1.Items[e.ItemIndex].FindControl("DropDownList1");//查找控件dropdownlist e.NewValues["Gender"] = ddlist.SelectedValue;//设置数据库的数据 } protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e) { if(e.Item.ItemType==ListViewItemType.InsertItem)//判断事件项是否为插入项。 { TextBox txtbox = (TextBox)e.Item.FindControl("GenderTextBox"); txtbox.Text ="男"; } if (e.Item.ItemType == ListViewItemType.DataItem)//判断事件项是否为数据绑定项。 { DropDownList ddlist = (DropDownList)e.Item.FindControl("DropDownList1"); if (ddlist != null)//如果为空则不是更新项, { ListViewDataItem lvdata = (ListViewDataItem)e.Item;//主要是xsd文件的引用 DataRowView dtview = (DataRowView)lvdata.DataItem;//强制类型dataset的运用 if (dtview!=null) { var row = (WebApplication3.DAL.DataSet1.T_PersonsRow)dtview.Row;//强制类型dataset的运用 ddlist.SelectedValue = row.Gender;//强制类型dataset的运用 } } } } } }
查看全文
相关阅读:
奥运圣火在家乡传递
Please stop reinventing the wheel (请不要重复发明轮子)
使用IDispatch::Invoke函数在C++中调用C#实现的托管类库方法
To invoke and to begin invoke, that is a question.
XML和JSON(JavaScript Object Notation)
Cloud Computing Is a Big Whiteboard
TRIE Data Structure
ASP.NET AJAX UpdatePanel 控件实现剖析
分布式计算、网格计算和云计算
系统架构设计师考试大纲(2009版)
原文地址:https://www.cnblogs.com/lzhp/p/2680819.html
最新文章
Let's say you have a phrase without any spaces eg. "thisisawesome".
Given an array of size n, find all the possible sub set of the array of size k
找到起始加油站,使得汽车能够环绕一周的问题
Take any two adjacent distinct characters and replace it with the third character.
Find the substring of length 3 which is present in the reverse order from the string
Minimum edit distance problem
根据color 集合,对一个整形数组排序
给定一个整数,求比该整数大的最小的整数,其数字能够组成一个回文
Given a number,find the next higher number using the same digits in the number.
ASP.NET MVC的全球化方案
热门文章
【Python】初识Python
C#绘制磁盘容量扇形图
执行CMD命令
解决SQL2005没有SQLEXPRESS
使用vs2005的c++在编译智能设备的应用程序出现的bug
有些往事我们总想回首,有些往事我们总是不堪回首
在vs2005中重载OnInitDialog
Windows Mobile学习笔记_关于CSpinButtonCtrl
Windows Mobile学习笔记_关于csliderbar和wm_hscroll消息处理
Persistent Data Structures(可持久化的数据结构)
Copyright © 2011-2022 走看看