⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addandeditbook.aspx

📁 asp.net 做的个人图书站点应用
💻 ASPX
字号:
<%@	Page Language="C#" MasterPageFile="~/Default.master" Title="此处是您的姓名 | 管理"%>

<script runat="server">

    protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }

    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
    {

    }

    protected void AddNewPhotoButton_Click(object sender, ImageClickEventArgs e)
    {
       // DropDownList temp = (DropDownList)GridView1.FindControl("DropDownList2");
        
     //   (DropDownList )GridView1.FindControl("DropDownList2").
      //  ObjectDataSource1.UpdateParameters.Add("categoryid",temp.SelectedValue);
      //  ObjectDataSource1.Update();
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        
    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (FormView1.Visible == false)
        {
            FormView1.Visible = true;
            ImageButton1.Visible = false;
        }
        else
            FormView1.Visible = false;
           
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        FormView1.Visible = false;
        ImageButton1.Visible = true;
    }
</script>

<asp:content id="Content1" contentplaceholderid="Main" runat="server">

	<div class="shim column"></div>
	
	<div class="page" id="admin-photos">
		<div id="sidebar">
			<h4>
                &nbsp;</h4>
            <h4>
                &nbsp;</h4>
            <h4>
                图书类别:</h4>
            <p>&nbsp;&nbsp;&nbsp;
                <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" Width="160px" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                </asp:DropDownList>&nbsp;<br />
                &nbsp;</p>
		</div>

		<div id="content">
			<h4>
                添加图书:</h4>
			<p>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                <asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" SkinID="Add" /></p>
			<asp:FormView ID="FormView1" Runat="server" 
				DataSourceID="ObjectDataSource1" DefaultMode="insert"
				BorderWidth="0px" CellPadding="0" OnPageIndexChanging="FormView1_PageIndexChanging" Visible="False" >
				<InsertItemTemplate>
					<asp:RequiredFieldValidator	ID="RequiredFieldValidator1" Runat="server" ErrorMessage="必须输入图书名。" ControlToValidate="PhotoFile" Display="Dynamic" Enabled="false" />
					<p>
                        图书封面上传:<br />
						<asp:FileUpload ID="PhotoFile" Runat="server" Width="416" FileBytes='<%# Bind("orginal") %>' CssClass="textfield" /><br />
                        图书名:<asp:TextBox ID="PhotoCaption" Runat="server" Width="155px" Text='<%# Bind("BookName") %>' CssClass="textfield" />&nbsp; ISDN:<asp:TextBox ID="TextBox1" runat="server" Width="99px" Text ='<%#Bind("ISDN") %>'></asp:TextBox>&nbsp;</p>
                    <p>
                        <asp:Label ID="Label1" runat="server" Text="类别:"></asp:Label>&nbsp;
                        <asp:DropDownList ID="DropDownList2" runat="server" Width="169px" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" SelectedValue='<%#Bind("CategoryID") %>'>
                        </asp:DropDownList></p>
                    <p>
                        <br />
                        图书概要:</p>
                    <p>
                        <asp:TextBox ID="TextBox2" runat="server" Height="148px" TextMode="MultiLine" Width="398px" Text='<%#Bind("BookTips") %>'></asp:TextBox>&nbsp;</p>
                    <p>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        &nbsp;&nbsp;
						<asp:ImageButton ID="AddNewPhotoButton" Runat="server" CommandName="Insert" skinid="add" OnClick="AddNewPhotoButton_Click"/>
                    </p>
				</InsertItemTemplate>
			</asp:FormView>
			<hr />
			<h4>
                此类别中的图书:</h4>
			<p>
                此类别中当前有以下。</p>
			<asp:gridview id="GridView1" runat="server" datasourceid="ObjectDataSource1" 
				datakeynames="BookID" cellpadding="6" EnableViewState="false"
				autogeneratecolumns="False" BorderStyle="None" BorderWidth="0px" width="420px" showheader="false" >
				<EmptyDataRowStyle CssClass="emptydata"></EmptyDataRowStyle>
				<EmptyDataTemplate>
					当前没有图书封面。
				</EmptyDataTemplate>
				<columns>
					<asp:TemplateField>
						<ItemStyle Width="50px" />
						<ItemTemplate>
							<table border="0" cellpadding="0" cellspacing="0" class="photo-frame">
								<tr>
									<td class="topx--"></td>
									<td class="top-x-"></td>
									<td class="top--x"></td>
								</tr>
								<tr>
									<td class="midx--"></td>
									<td><a href='Details.aspx?BookID=<%# Eval("BookID") %>&Page=<%# ((GridViewRow)Container).RowIndex %>'>
										<img src='../Handler.ashx?Size=S&BookID=<%# Eval("BookID") %>' class="photo_198" style="border:2px solid white;width:50px;" alt='缩略图,照片编号 <%# Eval("BookID") %>' /></a></td>
									<td class="mid--x"></td>
								</tr>
								<tr>
									<td class="botx--"></td>
									<td class="bot-x-"></td>
									<td class="bot--x"></td>
								</tr>
							</table>
						</ItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField>
						<ItemStyle Width="150px" />
						<ItemTemplate>
						    <div >
						    <b><%#Server.HtmlEncode(Eval("BookName").ToString ()) %></b>
						    </div>
							<div style="width:100%;text-align:right;">
								<asp:ImageButton ID="ImageButton2" Runat="server" CommandName="Edit" SkinID="editbutton" Width="42px" />
								<asp:ImageButton ID="ImageButton3" Runat="server" CommandName="Delete"  SkinID="delete" />
							</div>
						</ItemTemplate>
                        <EditItemTemplate>
                                                     
							<div style="width:100%;text-align:right;">
										
					
                        图书封面上传:<br />
						<asp:FileUpload ID="PhotoFile" Runat="server" Width="255px" FileBytes='<%# Bind("orginal") %>' CssClass="textfield" /><br />
                        图书名:<asp:TextBox ID="PhotoCaption" Runat="server" Width="151px" Text='<%# Bind("BookName") %>' CssClass="textfield" />&nbsp;<br />
					<asp:RequiredFieldValidator	ID="RequiredFieldValidator1" Runat="server" ErrorMessage="必须输入图书名。" ControlToValidate="PhotoFile" Display="Dynamic" Enabled="false" />
                    <br />
                    ISDN:<asp:TextBox ID="TextBox8" runat="server" Width="150px" Text='<%#Bind("ISDN") %>'>' ></asp:TextBox>&nbsp;<br />
                        图书概要:<asp:TextBox ID="TextBox3" runat="server" Height="65px" TextMode="MultiLine" Text='<%#Bind("BookTips") %>'></asp:TextBox>
                                <p>
                                </p>
                    
                        <asp:Label ID="Label3" runat="server" Text="类别:"></asp:Label>
                        <asp:DropDownList ID="DropDownList3" runat="server" Width="182px"  DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" SelectedValue='<%#Bind("CategoryID") %>' >
                        </asp:DropDownList><br />
						<asp:ImageButton ID="AddNewPhotoButton" Runat="server" CommandName="Update" skinid="save"/>
                        &nbsp; <asp:ImageButton ID="ImageButton5" Runat="server" CommandName="Cancel"  SkinID="cancel" OnClick="ImageButton5_Click" /><p>
                        </p>
				
			                          								
							</div>
						
                        </EditItemTemplate>
						
					</asp:TemplateField>
				</columns>
			</asp:gridview>
		</div>

	 </div>
	
	<asp:ObjectDataSource ID="ObjectDataSource1" Runat="server" TypeName="BookManager" 
	 UpdateMethod ="EditBook"
	InsertMethod="AddBook" 
	SelectMethod ="GetBookbyCategoryAndName"  
	 DeleteMethod="RemoveBook"
	 >
		<SelectParameters>
			<asp:ControlParameter Name="CategoryID"   ControlID="DropDownList1" Type="Int32" PropertyName="SelectedValue"  />
		</SelectParameters>
		 <%--<DeleteParameters>
          <asp:ControlParameter ControlID="GridView1" Name />
        </DeleteParameters>--%>
	</asp:ObjectDataSource>
	
	
	 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BookShow %>"
                    SelectCommand="SELECT [CategoryID], [CategoryName] FROM [BookCategory]"></asp:SqlDataSource>
	
	
	 
</asp:content>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -