星期二, 2月 01, 2011

[ASP.Net][轉載翻譯筆記]GridView的一些小技巧

這篇文章是在dotnetcurry上的前五大高閱讀率的文章,
今天在dotnetcurry的FB上點了文章連過去後才看到,
覺得相當實用,避免下次又要花時間翻譯過,
這邊自己做點翻譯紀錄,下次可以比較快找到我要的東西...囧
翻得很隨性,看不懂的話建議點回原文看,Sample Code也比較多~

原文出處:GridView Tips and Tricks using ASP.NET 2.0 from Suprotim Agarwal



Tip 1: Add, Update, Delete Records in a Gridview using SqlDataSource
沒啥好說的...去點原文就可以了,這個還蠻基本的,我覺得...

Tip 2: Paging and Sorting a GridView without Refreshing a Page
如果不要POSTBACK GRIDVIEW上的資料,然後做到GRIDVIEW的資料排序。
EnableSortingAndPagingCallbacks這個屬性設定為True即可
不過,有個前提,GridView裡不能有Template Fields

Tip 3: Pop-up a Confirmation box before Deleting a row in GridView
當要刪除row時,會跳出提醒視窗
加一個template field,並丟一個button在裡面,然後對這個button的內容為
Button ID="btnDel" runat="server" Text="Delete"
CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete the record?');"

Tip 4: Display details of the Row selected in the GridView
取得選取的ROW的詳細資料

Tip 5: Retrieve Details of the Row being Modified in GridView
取得編輯狀態中,ROW的詳細資料

Tip 6: Retrieve Details of the Row being Deleted in GridView
取得正在被刪除狀態中,ROW的詳細資料

Tip 7: Cancelling Update and Delete in a GridView
在GridView取消"更新"與"刪除"

Tip 8: Paging and Sorting in GridView without using Datasource control
不透過DataSource這個控制項更新GridView

Tip 9: Delete Multiple rows in a GridView
在GridView一次刪除多行
連到另一篇在dotnetcurry上的文章

Tip 10: Export GridView To Excel
匯出GridView的資料到Excel

沒有留言: