LUpin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 閱讀技術文章_.Net(WebForm)_那些資料控制向的區別_GridView、DataGrid、DataList、Repeater、ListView、DetailsView、FormView ---- ###### tags: `技術文章` `web form` `.NET` `C#` 感激所有願意分享知識的人,筆記內成就皆不在我 --- [GridView、DataGrid、DataList、Repeater、ListView、DetailsView、FormView 的區別](https://dotblogs.com.tw/codeing_learning_diary/2019/05/02/234824) [詳解ASP.NET數據綁定操作中Repeater控件的用法](https://www.itread01.com/articles/1475901015.html) --- 因為我個人很常疑問, 這些資料顯示的控制向 為什麼分這麼多種??? 非常不好記!!!! 裡面屬性方法都不完全相同, 有些可用, 換一種用不可用了 所以乾脆寫(紀錄)下來 > Repeater自由度最高 分頁需手寫 > GridView可以直接綁定數據 可做為Degug的方法 <br /> <br /> <br /> GridView、DataGrid、DataList、Repeater、ListView、DetailsView、FormView 的區別 ### GridView控制項 特徵:以「table」形式顯示資料,可以進行排序、分頁、翻閱資料及編輯和刪除「單個記錄」功能。 簡要特徵:一行一條記錄,就像新聞列表一樣;帶分頁功能。 <br /> <br /> <br /> ### DetailsView 控制項 特徵:一次呈現一列的記錄,並提供翻閱多條記錄以及插入、更新和刪除記錄的功能。 簡要特徵:一列記錄,一行一個字段;帶分頁功能。 <br /> <br /> <br /> ### FormView 控制項 特徵:FormView 控制項與 DetailsView 控制項類似,它一次呈現資料源中的一條記錄,並提供翻閱多條記錄以及插入、更新和刪除記錄的功能。不過,FormView 控制項與 DetailsView 控制項之間的差別在於:DetailsView 控制項使用基於表格的佈局,在這種佈局中,資料記錄的每個欄位都顯示為控制項中的一行。而 FormView 控制項則不指定用於顯示記錄的預定義佈局。實際上,您將創建包含控制項的範本,以顯示記錄中的各個欄位。該範本包含用於設置表單佈局的格式、控制項和綁定運算式。 簡要特徵:一列記錄,自由定制;帶分頁功能。 > 修正 formview是基于html布局,不是表格布局 <br /> <br /> <br /> ### ListView 控制項 特徵:這個控制項既可實現像GridView 一樣的效果,也可實現像DataList 一樣的效果(怪不得名字叫ListView),這東西應用起來也要複雜些。要點是:LayoutTemplate 下面必須有一個服務器端控件,即runat="server",其ID 必須為itemPlaceholder(除非更改ListView 的ItemPlaceholderID),注意大小寫,ItemTemplate 模板中的內容輸出時就是插入到itemPlaceholder 的。 但ListView分頁卻不是那麼複雜,在LayoutTemplate模板中拖入一個DataPager控件,指定好DataPager的Fields就可以了。但DataPager並不會向DataSource發送startRowIndex和maximumRows這兩個參數,也就是說這種分頁是取出所有的記錄,只是顯示部分,並不是一種高效的分頁。 簡要特徵:自由定制,功能強大;應用複雜;分頁功能需要手寫。 <br /> <br /> <br /> ### DataList 控制項 特徵DataList控制項以「table」的形式呈現數據,通過該控件,您可以使用不同的佈局來顯示數據記錄,例如,將數據記錄排成列或行的形式。您可以對DataList控件進行配置,使用戶能夠編輯或刪除表中的記錄。(DataList控件不使用數據源控件的數據修改功能;您必須自己提供此代碼。)DataList控件與Repeater控件的不同之處在於:DataList控件將項顯式放在HTML表中,而Repeater控件則不然。 簡要特徵:一行可以有多條記錄,就像圖片列表一樣;分頁功能需要手寫。 <br /> <br /> <br /> ### Repeater 控制項 特徵:Repeater控制項使用數據源返回的一組記錄呈現只讀列表。與FormView控件類似,Repeater控件不指定內置佈局。您可以使用模板創建Repeater控件的佈局。 簡要特徵:自由定制;分頁功能需要手寫。 --- --- ## 數據綁定操作中Repeater控件的用法 ![](https://i.imgur.com/WPoYGGp.png) ![](https://i.imgur.com/A5Cc0yp.png) ### 綁定控制項之Repeater .NET封裝了多種數據綁定控制項 如GridView、DataList等但該篇文章將會從Repeater入手,因為Repeater只提供了基本的數據綁定模板,沒有內置其它分頁等功能,所以它是最原始的數據綁定控制項,只要能夠熟練運用Repeater控制項其它的綁定控制項也就很簡單了。 1. Repeater簡介 > Repeater 是基本模板化數據列表。 它不像GridView控件一樣能夠可視化的設計格式或樣式,因此開發時在控件模板中必須顯式聲明所有格式、格式和樣式標記。 另外Repeater控件沒有內置選擇、排序、編輯、分頁等功能,它只提供了基本的數據綁定,但是它為開發人員提供了Itemcommand 事件,該事件支持在控件中收發命令。 想要綁定數據,模板是必不可少的,Repeater控件同樣支持數據模板,而且還可以在模板中添加想要的標簽,它主要用法如圖 >> 每個 Repeater 控件必須定義 ItemTemplate。 2. 控件使用技巧 上文講解了Repeater基本的使用方法及它的一些基本特性,接下來做幾個經典的示例來運用Repeater控件。 > 1. 數據綁定之刪除、編輯 該示例將會使用Asp.net的前臺和後臺結合來實現顯示數據,並能夠編輯和刪除數據。 刪除頁面: ![](https://i.imgur.com/fKDqmue.png) ![](https://i.imgur.com/2k8zwSF.png) ![](https://i.imgur.com/3F737d9.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully