ASP.NET笔记之 ListView 与 DropDownList的使用(2)


<%@ 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="https://www.jb51.net/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 runat="server">
     <div>

         <asp:ObjectDataSource runat="server"
             DeleteMethod="Delete" InsertMethod="Insert"
             OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
             TypeName="友情链接.ADL.DataSet1TableAdapters.T_LinksTableAdapter"
             UpdateMethod="Update">
             <DeleteParameters>
                 <asp:Parameter Type="Int64" />
             </DeleteParameters>
             <InsertParameters>
                 <asp:Parameter Type="Int32" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
             </InsertParameters>
             <UpdateParameters>
                 <asp:Parameter Type="Int32" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="String" />
                 <asp:Parameter Type="Int64" />
             </UpdateParameters>
         </asp:ObjectDataSource>

     </div>
     <asp:ListView runat="server" DataKeyNames="ID"
         DataSourceID="ObjectDataSource1" InsertItemPosition="LastItem"
         onitemdatabound="ListView1_ItemDataBound"
         oniteminserting="ListView1_ItemInserting"
         onitemupdating="ListView1_ItemUpdating"
         onitemcreated="ListView1_ItemCreated">

         <EditItemTemplate>
             <tr>
                 <td>
                     <asp:Button runat="server" CommandName="Update" Text="更新" />
                     <asp:Button runat="server" CommandName="Cancel" Text="取消" />
                 </td>
                 <td>
                     <asp:TextBox runat="server" Text='<%# Bind("SeoNo") %>' />
                 </td>
                 <td>
                     <asp:TextBox runat="server"
                         Text='<%# Bind("SiteName") %>' />
                 </td>
                 <td>
                    <asp:DropDownList runat="server">
                      <asp:ListItem Value="Text">文本</asp:ListItem>
                      <asp:ListItem Value="Pic">图片</asp:ListItem>
                    </asp:DropDownList>
                 </td>
                 <td>
                     <asp:TextBox runat="server" Text='<%# Bind("SiteUrl") %>' />
                 </td>
                 <td>
                     <asp:TextBox runat="server" Text='<%# Bind("LogoUrl") %>' />
                 </td>
             </tr>
         </EditItemTemplate>
         <EmptyDataTemplate>
             <table runat="server"
                >
                 <tr>
                     <td>
                         未返回数据。</td>
                 </tr>
             </table>
         </EmptyDataTemplate>
         <InsertItemTemplate>
             <tr>
                 <td>
                     <asp:Button runat="server" CommandName="Insert" Text="插入" ValidationGroup="Insert" />
                     <asp:Button runat="server" CommandName="Cancel" Text="清除" />
                 </td>
                 <td>
                     <asp:TextBox ValidationGroup="Insert" runat="server" Text='<%# Bind("SeoNo") %>' />
                     <asp:RequiredFieldValidator ValidationGroup="Insert" runat="server" ErrorMessage="*" ControlToValidate="SeoNoTextBox">
                     </asp:RequiredFieldValidator>
                     <asp:CompareValidator ValidationGroup="Insert" runat="server" ErrorMessage="序号必须为整数" ControlToValidate="SeoNoTextBox" Operator="DataTypeCheck" Type="Integer">
                     </asp:CompareValidator>
                 </td>
                 <td>
                     <asp:TextBox ValidationGroup="Insert" runat="server" MaxLength="50"
                         Text='<%# Bind("SiteName") %>' />
                     <asp:RequiredFieldValidator ValidationGroup="Insert" runat="server" ErrorMessage="*" ControlToValidate="SiteNameTextBox">
                     </asp:RequiredFieldValidator>
                 </td>
                 <td>
                    <asp:DropDownList ValidationGroup="Insert" runat="server" >
                      <asp:ListItem Value="Text">文本</asp:ListItem>
                      <asp:ListItem Value="Pic">图片</asp:ListItem>
                    </asp:DropDownList>
                 </td>
                 <td>
                     <asp:TextBox ValidationGroup="Insert" runat="server" Text='<%# Bind("SiteUrl") %>' />
                     <asp:RequiredFieldValidator ValidationGroup="Insert" runat="server" ErrorMessage="*" ControlToValidate="SiteUrlTextBox">
                     </asp:RequiredFieldValidator>
                 </td>
                 <td>
                     <asp:TextBox ValidationGroup="Insert" runat="server" Text='<%# Bind("LogoUrl") %>' />
                 </td>
             </tr>
         </InsertItemTemplate>
         <ItemTemplate>
             <tr>
                 <td>
                     <asp:Button runat="server" CommandName="Delete" Text="删除" />
                     <asp:Button runat="server" CommandName="Edit" Text="编辑" />
                 </td>
                 <td>
                     <asp:Label runat="server" Text='<%# Eval("SeoNo") %>' />
                 </td>
                 <td>
                     <asp:Label runat="server" Text='<%# Eval("SiteName") %>' />
                 </td>
                 <td>
                    <asp:DropDownList runat="server" Enabled="false">
                      <asp:ListItem Value="Text">文本</asp:ListItem>
                      <asp:ListItem Value="Pic">图片</asp:ListItem>
                    </asp:DropDownList>
                 </td>
                 <td>
                     <asp:Label runat="server" Text='<%# Eval("SiteUrl") %>' />
                 </td>
                 <td>
                     <asp:Label runat="server" Text='<%# Eval("LogoUrl") %>' />
                 </td>
             </tr>
         </ItemTemplate>
         <LayoutTemplate>
             <table runat="server">
                 <tr runat="server">
                     <td runat="server">
                         <table runat="server"
                            >
                             <tr runat="server">
                                 <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 runat="server">
                             </tr>
                         </table>
                     </td>
                 </tr>
                 <tr runat="server">
                     <td runat="server"
                        >
                         <asp:DataPager runat="server">
                             <Fields>
                                 <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
                                     ShowLastPageButton="True" />
                             </Fields>
                         </asp:DataPager>
                     </td>
                 </tr>
             </table>
         </LayoutTemplate>
     </asp:ListView>
     </form>
 </body>
 </html>


您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgsxw.html