时间:2016-02-15 23:16 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【ASP.NET笔记之 ListView 与 DropDownList的使用】,下面是详细的讲解!
ASP.NET笔记之 ListView 与 DropDownList的使用
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LinkUrl_Admin.aspx.cs" Inherits="友情链接.LinkUrl_Admin" %>
<!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="Scripts/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
function onLinkTypeChange(urlType, logoID) {
if ($(urlType).val()=="Text") {
$("input:text[myid=" + logoID + "]").hide();
//$("#" + logoID).hide(); //传到到客户端不是客户端的id
//$("#ListView1_LogoURLTextBox").hide();//真正的id
}
else {
$("input:text[myid=" + logoID + "]").show();
//$("#" + logoID).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="友情链接.ADL.DataSet1TableAdapters.T_LinksTableAdapter"
UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_ID" Type="Int64" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="SeoNo" Type="Int32" />
<asp:Parameter Name="SiteName" Type="String" />
<asp:Parameter Name="sLinkType" Type="String" />
<asp:Parameter Name="SiteUrl" Type="String" />
<asp:Parameter Name="LogoUrl" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="SeoNo" Type="Int32" />
<asp:Parameter Name="SiteName" Type="String" />
<asp:Parameter Name="sLinkType" Type="String" />
<asp:Parameter Name="SiteUrl" Type="String" />
<asp:Parameter Name="LogoUrl" Type="String" />
<asp:Parameter Name="Original_ID" Type="Int64" />
</UpdateParameters>
</asp:ObjectDataSource>
</div>
<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="background-color: #999999;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
</td>
<td>
<asp:TextBox ID="SeoNoTextBox" runat="server" Text='<%# Bind("SeoNo") %>' />
</td>
<td>
<asp:TextBox ID="SiteNameTextBox" runat="server"
Text='<%# Bind("SiteName") %>' />
</td>
<td>
<asp:DropDownList ID="ddlsLinkType" 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="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
未返回数据。</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" ValidationGroup="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
</td>
<td>
<asp:TextBox ID="SeoNoTextBox" ValidationGroup="Insert" runat="server" Text='<%# Bind("SeoNo") %>' />
<asp:RequiredFieldValidator ValidationGroup="Insert" ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="SeoNoTextBox">
</asp:RequiredFieldValidator>
<asp:CompareValidator ValidationGroup="Insert" ID="CompareValidator1" runat="server" ErrorMessage="序号必须为整数" ControlToValidate="SeoNoTextBox" Operator="DataTypeCheck" Type="Integer">
</asp:CompareValidator>
</td>
<td>
<asp:TextBox ID="SiteNameTextBox" ValidationGroup="Insert" runat="server" MaxLength="50"
Text='<%# Bind("SiteName") %>' />
<asp:RequiredFieldValidator ValidationGroup="Insert" ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="SiteNameTextBox">
</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlsLinkType" ValidationGroup="Insert" runat="server" >
<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 ValidationGroup="Insert" ID="RequiredFieldValidator3" 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="background-color: #E0FFFF;color: #333333;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="删除" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="编辑" />
</td>
<td>
<asp:Label ID="SeoNoLabel" runat="server" Text='<%# Eval("SeoNo") %>' />
</td>
<td>
<asp:Label ID="SiteNameLabel" runat="server" Text='<%# Eval("SiteName") %>' />
</td>
<td>
<asp:DropDownList ID="ddlsLinkType" 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="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color: #E0FFFF;color: #333333;">
<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="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
</form>
</body>
</html>
关于ASP.NET笔记之 ListView 与 DropDownList的使用的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【asp】asp.net ubb使用代码-net-ubb使用
- 【默认图片】图片不存在使用默认图片代替的实例
- 【asp】asp.net 页面转向 Response.Redirect Ser
- 【jQuery】jQuery实现倒计时跳转的例子-倒计时跳
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
