1、Repeater用来显示数据、ListView用来操作数据
InsertItemTemplate和updateItemTemplate
**Eval(显示数据)和Bind(双向绑定:不仅是需要展现,更需要把数据绑定到数据库中)
ItemPlaceholderID:占位符,决定占位,把头部(之上)和尾部(之下)分隔开
ItemTemplate:展示功能
自动生成的ListView需要调整的地方
(1、生成的样式要提到style中,不要用内联的方式
(2、ItemTemplate里面一半没必要用<asp:Label>展示只读数据,所以可以直接输出
<%#Eval("id")%>
(3、LayoutTemplate中必须有一个ItempPlaceholderID 的服务端控件
(4、LayoutTemplate中表头的位置要汉化,所有template中的不需显示的字段需删除或更改位置
2、事件
流程同Repeater:
//首先判断数据行的类型
e.Item.ItemType==ListViewItemType.DataItem
//把e.Item转化成ListViewDataItem才能拿到DataItem
ListViewDataItem lvDataItem=(ListViewDataItem)e.Item;
DataRowView rowView=(DataRowView)lvDataItem.DataItem;
//获得某一列
var xRow=(...DAL.DataSet1.T_UserRow)rowVIew.Row;
//获得某一列的值
xRow.Age、xRow.sName...etc.
3、具体注意
(1、设定相应的按钮、控件、Validator为童颜的ValidationGroup,
防止不同模板中的Validator互相干扰,
(2、将Cancel按钮中的CausesValidation="false"使得插入修改数据时
可以取消操作,这样即使在同一个分组内也可以不互相影响
4、给InsertItemplate增加默认值
//在ItemCreate属性中进入函数
if(e.Item.ItemType==ListViewItemType.InsertItem){
TextBox AgeText=(TextBox)e.Item.FindControl("AgeID");
AgeText.Text="20";
}
5、主键Guid:插入到数据库
(1、ListView的ItemInserting属性:
//要插入到数据库之前的数据的键值对
e.values["id"]=Guid.NewGuid();
(2、ListView的ItemUpdateing属性:
e.ItemIdex
e.OldValues//更新前的值
e.NewValues["Age"]//更新后的值
e.Cancel=true;//取消非法数据插入
ObjectDataSource
绑定id为guid 类型的时候
6、DropDrownList
(1、
//包含在DropDrownList中的项
<asp:ListItem value="man">男</asp:ListItem>
(2、
**后台代码:更新的时候
//找到ListView
//ListView1.Item[e.ItemIndex].FindControl("ID");
//它是一个DropViewList
DropDrownList d=(DropDrownList)listView1.Item[e.ItemIndex].FindControl("ID");
//赋值
e.NewValues=["字段"]=d.SelectedValue;
(3、
**后台代码:实现编辑时显示原先的数据
//有数据行
if(e.Item.ItemType==ListVIewDataList.DataItem){
//取控件
DropDownList d=(DropDownLIst)e.Item.FindControl("ID");
if(d!=null){
//取到这一行绑定的数据
ListViewDataItem lv=(ListViewDataItem)e.Item;
DataRowItem row=(dataRowItem)lv.DataItem;
//如果这一行有数据
if(row!=null){
//读取数据库该Row的值
var myRow=(项目名称.DAL.DataSetUsers.T_Users)row.Row;
//将读取打偶的Row值设置为下拉菜单中的选项
d.SelectedValue=myRow.字段;
}
}
}
(4、 可以看不可以用 Enabled="false
友情链接管理:
效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAuYAAACCCAIAAACFAZphAAAWb0lEQVR4nO2dTdKjthaGvRV2w+TuxZNeAZU9fFlDD9jAV70DBj1IJZWkbydxfm5S2YPvAFsIHelIYDCS/DwDF4gjOOjo57UQ9ukKAAAAkD2nox0AAAAAiINkAQAAgAJAsgAAAEABIFkAAACgAJAsAAAAUABIFgAAACgAJAsAAAAUAJIFAAAACgDJAgAAAAWAZAEAAIACQLIAAABAASBZAAAAoACQLKBxOp1OJyrJa+ENekpNoLYYNimKisszemuOwVJ7k9i27SL7Wgt8E5YWspJldTkTHoiQ2FmEeJqfINFDo4RJJqZE88Ujbt9+aNsx1mNRR3kmVrCogZ4ldBUky4YsLWQly+pyJjwwI2F0S+1Yaf+Ho/cmxialT0kcY5R68gqYW5YbifbpeQvidDp1XZfepVxFIaTbO4lIlg1ZWshKltXlTHhgxorKFMpC+z8cvTcxNs5g6R0Y9GgyADgk3rszMCuJRXM6nbquC+2Gsiy6d6cAx2qfKFmKLfBL387bajfser2lhSyzPF7OBYUHnkF0AEsfmUpr/xXi9CZydxiGRYOrtxp4z/NS0Q+1lPS2s3nPnjMna9JFHnJIrFpOAdqjqbfw6ynw4VaSO8uV63V5Icssj5dzaeGBnVEqU+h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oi+PLtt369Ir2iflYDoQyhSZafE2iaxmxIpFkoexTZOBf5plzXa6bkTfFtr3DBcyGyVbLhG0POxImuQtI0ynqvqJ/VQChDaJLlpxhjEzXb8mjokNdMRzbOlFzeS9huex1wDFb4tle44LkQ2SrZ6qfkvJb6oaXXXeQV9bMaCGUITbL8mBOycR7t0QQdR60Q2SrZfC3LUVA/a4VQhtAkyw85IRvn0R5N0HHUCpGtEiQLZA6hDIFk2QA6jlohslWCZIHMIZQhNMnyfU7Ixnm0RxN0HLVCZKtknWTJkwfvC/KEUIbQJMt3OSEb59EeTUjfoBqIbJVs241mwtGFCltydG3KFE2y5EbO7u0fKQAAgJcmKFkAAAAA8gHJAgAAAAWAZAEAAIACQLIAAABAASBZAAAAoACQLAAAAFAASBYAAAAoACQLAAAAFACSBQAAAAoAyQIAAAAFgGQBAACAAkCyAAAAQAEgWQAAAKAAkCwAAABQAEgWAAAAKAAkCwAAABQAkgUAAAAK4P+DdhmPTxaNpQAAAABJRU5ErkJggg==" alt="" />
存在问题总结:
(1、警告 1 元素“ListView”不是已知元素。原因可能是网站中存在编译错误,或者缺少 web.config 文件。 E:\code\Projects\WebSite_zzl01\友情链接\LinkUrl_Admin.aspx 39 10 友情链接
(2、onLinkTypeChange(this,'" + logoID.ClientID + "') 中传给前台javascript的ID不是客户端的ID,会导致显示和隐藏的功能无法实现,所以增加一个myID
: logoID.Attributes["myid"] = logoID.ClientID; 来传递参数
LinkUrl_Admin.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ListView.DAL.DataSetLinksTableAdapters; namespace ListView
{
public partial class LinksMer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if(e.Item.ItemType== ListViewItemType.DataItem)
{
//ListViewItem lvi = (ListViewItem)e.Item.DataItem;
DataRowView drv = (DataRowView)e.Item.DataItem;
if(drv!=null)
{
var ll=(ListView.DAL.DataSetLinks.T_LinksRow)drv.Row;
DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
DropDownList1.SelectedValue = ll.LinkType.ToString();
}
} } protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
e.Values["LinkType"] = DropDownList1.SelectedValue;
DataRowView drv = (DataRowView)e.Item.DataItem;
} protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
DropDownList DropDownList1 = (DropDownList)ListView1.Items[e.ItemIndex].FindControl("DropDownList1");
e.NewValues["LinkType"]= DropDownList1.SelectedValue;
} protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
//对于Insert、Item界面的初始化在ItemCreated比在ItemDataBound更好
if (e.Item.ItemType == ListViewItemType.DataItem || e.Item.ItemType == ListViewItemType.InsertItem)
{
DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
TextBox LogoURLTextBox = (TextBox)e.Item.FindControl("LogoURLTextBox");
if (DropDownList1 != null&&LogoURLTextBox!=null)
{
LogoURLTextBox.Attributes["myid"] = LogoURLTextBox.ClientID;
DropDownList1.Attributes["onchange"] = "onLinkTypeChange(this,'" + LogoURLTextBox.ClientID + "')";
if (DropDownList1.SelectedValue == "Text")
{
//LogoURLTextBox.Visible = false;
LogoURLTextBox.Style["display"] = "none";
}
}
}
}
}
}
LinkUrl_Admin.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LinksMer.aspx.cs" Inherits="ListView.LinksMer" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function onLinkTypeChange(src,logoTextId) {
if($(src).val()=="Text") {
$("input:text[myid=" + logoTextId+"]").hide();
// alert(logotextid);获取控件失败,待处理
//alert("input:text[myid=" + logoTextId + "]");
}
else {
$("input:text[myid=" + logoTextId + "]").show();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="ListView.DAL.DataSetLinksTableAdapters.T_LinksTableAdapter"
UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_Id" Type="Int64" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="SeqNo" Type="Int32" />
<asp:Parameter Name="SiteName" Type="String" />
<asp:Parameter Name="LinkType" Type="String" />
<asp:Parameter Name="SiteURL" Type="String" />
<asp:Parameter Name="LogoURL" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="SeqNo" Type="Int32" />
<asp:Parameter Name="SiteName" Type="String" />
<asp:Parameter Name="LinkType" Type="String" />
<asp:Parameter Name="SiteURL" Type="String" />
<asp:Parameter Name="LogoURL" Type="String" />
<asp:Parameter Name="Original_Id" Type="Int64" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Id"
DataSourceID="ObjectDataSource1" InsertItemPosition="LastItem"
onitemdatabound="ListView1_ItemDataBound"
oniteminserting="ListView1_ItemInserting"
onitemupdating="ListView1_ItemUpdating"
onitemcreated="ListView1_ItemCreated">
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
</td>
<td>
<asp:TextBox ID="SeqNoTextBox" runat="server" Text='<%# Bind("SeqNo") %>' />
</td>
<td>
<asp:TextBox ID="SiteNameTextBox" runat="server"
Text='<%# Bind("SiteName") %>' />
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="Text">文本</asp:ListItem>
<asp:ListItem Value="Pic">图片</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="SiteURLTextBox" runat="server" Text='<%# Bind("SiteURL") %>' />
</td>
<td>
<asp:TextBox ID="LogoURLTextBox" runat="server" Text='<%# Bind("LogoURL") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
未返回数据。</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" ValidationGroup="insert" CommandName="Insert" Text="插入" />
<asp:Button ID="CancelButton" runat="server" ValidationGroup="insert" CommandName="Cancel" Text="清除" />
</td>
<td>
<asp:TextBox ID="SeqNoTextBox" runat="server" ValidationGroup="insert" Text='<%# Bind("SeqNo") %>' />
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ValidationGroup="insert" ErrorMessage="*" ControlToValidate="SeqNoTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:CompareValidator
ID="CompareValidator1" runat="server" ValidationGroup="insert" ErrorMessage="必须为整数" ControlToValidate="SeqNoTextBox" Type="Integer" Operator="DataTypeCheck" Display="Dynamic"></asp:CompareValidator>
</td>
<td>
<asp:TextBox ID="SiteNameTextBox" runat="server" ValidationGroup="insert" MaxLength="50"
Text='<%# Bind("SiteName") %>' />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ValidationGroup="insert" ErrorMessage="*" ControlToValidate="SiteNameTextBox"></asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="DropDownList1" ValidationGroup="insert" runat="server" AutoPostBack="False">
<asp:ListItem Value="Text">文本</asp:ListItem>
<asp:ListItem Value="Pic">图片</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="SiteURLTextBox" ValidationGroup="insert" runat="server" Text='<%# Bind("SiteURL") %>' /><asp:RequiredFieldValidator
ID="RequiredFieldValidator3" ValidationGroup="insert" runat="server" ErrorMessage="*" ControlToValidate="SiteURLTextBox"></asp:RequiredFieldValidator>
</td>
<td>
<asp:TextBox ID="LogoURLTextBox" ValidationGroup="insert" runat="server" Text='<%# Bind("LogoURL") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="删除" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="编辑" />
</td>
<td>
<asp:Label ID="SeqNoLabel" runat="server" Text='<%# Eval("SeqNo") %>' />
</td>
<td>
<asp:Label ID="SiteNameLabel" runat="server" Text='<%# Eval("SiteName") %>' />
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" Enabled="false">
<asp:ListItem Value="Text">文本</asp:ListItem>
<asp:ListItem Value="Pic">图片</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Label ID="SiteURLLabel" runat="server" Text='<%# Eval("SiteURL") %>' />
</td>
<td>
<asp:Label ID="LogoURLLabel" runat="server" Text='<%# Eval("LogoURL") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
</th>
<th runat="server">
序号</th>
<th runat="server">
网站名</th>
<th runat="server">
类型</th>
<th runat="server">
连接地址</th>
<th runat="server">
Logo地址</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView> </div>
</form>
</body>
</html>