블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Category

Recent Post

Recent Comment

Archive

2009. 10. 12. 21:35 .Net Project/ASP.NET 3.5 Sp1
반응형
 Upload/List.aspx



 <%@ Page Language="C#" AutoEventWireup="true"
         CodeFile="List.aspx.cs" Inherits="Upload_List" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <img src="images/가인.png" style="height: 163px; width: 173px" />
    <asp:GridView ID="ctlUploadList" runat="server"
        AutoGenerateColumns ="false" AllowPaging="true"
       
        PageSize="3">
        <Columns>
            <asp:BoundField DataField="Num" HeaderText="번호" />
            <asp:HyperLinkField DataTextField="Title" HeaderText="제목"
                DataNavigateUrlFormatString="View.aspx?Num={0}"
                DataNavigateUrlFields="Num" />
            <asp:TemplateField HeaderText="파일">
                <ItemTemplate>
                        <a href= 'files/<%# Eval("FileName") %>'>
                        <%# Eval("FileName") %>
                        </a>                    
                                           
                        <asp:HyperLink ID="HyperLink1" runat="server"  
                            NavigateUrl='<%# "~/Upload/files/" + Eval("FileName") %>' >
                            <%# Eval("FileName") %>
                        </asp:HyperLink>
                        
                    <asp:HyperLink ID="HyperLink2" runat="server" 
                     NavigateUrl='<%# "Down.aspx?FileName=" + Eval("FileName") %>'>
                      <img src="images/윤아.png" border="0" alt="다운로드"
                                                                width="30px" height="30px" />       
                      </asp:HyperLink>
                        
                      <%# FuncFileLink(Eval("FileName")) %>            
               
                </ItemTemplate>                      
            </asp:TemplateField>                        
        </Columns>  
    </asp:GridView>
    <asp:DropDownList ID="SearchField" runat="server">
        <asp:ListItem Value="Name">이름</asp:ListItem>
        <asp:ListItem Value="Title">제목</asp:ListItem>
        <asp:ListItem Value="Content">내용</asp:ListItem>
    </asp:DropDownList>
   
    <asp:TextBox ID="SearchQuery" runat="server"></asp:TextBox> <br />
    <asp:Button ID="btnSearch" runat="server" Text="검색" 
                           onclick="btnSearch_Click" /> &nbsp
    <asp:Button ID="btnWrite" runat="server" Text="글쓰기" 
                           onclick="btnWrite_Click" /> <br />
      </div>
    </form>
</body>
</html>


 Upload.List.Cs

using System;

public partial class Upload_List : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Display();
        }
    }

    private void Display()
    {
        UploadBiz ub = new UploadBiz();
        this.ctlUploadList.DataSource = ub.ListUpload();
        this.ctlUploadList.DataBind();
      
    }
   
    /// <summary>
    /// 검색관련
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
   
protected void btnSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect(
                String.Format(
                    "Search.aspx?SearchField={0}&SearchQuery={1}"
                    , SearchField.SelectedValue
                    , SearchQuery.Text));
    }

    /// <summary>
    /// 쓰기관련
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
   
protected void btnWrite_Click(object sender, EventArgs e)
    {
        Response.Redirect("Write.aspx");
    }

    //코드 비하인트 페이지에서 링크 만들기
    protected string FuncFileLink(object fileName)
    {
        string name = Convert.ToString(fileName);
        if (!String.IsNullOrEmpty(name))
        {
            return "<a href='Down.aspx?FileName=" + name + "'>다운</a>";
        }
        else
        {
            return "-"; //파일이 첨부되지 않았다면...
        }
    }
}



반응형
posted by Magic_kit