摘要: 一,ViewData,ViewBag與TempDataASP.NET MVC架構中,通過繼承在Controller中的ViewData,ViewBag和TempData和View頁面進行資料的存取,並且適合於少量的資料傳遞。1.1 ViewBagViewBag可以產生動態屬性,我們新建項目中看到Vi... 阅读全文
posted @ 2014-10-02 18:24 hishanghai 阅读(1315) 评论(1) 推荐(1) 编辑
摘要: 一,Controller簡介Controller擔任了資料傳遞的角色,負責流程控制,決定存取哪個Model以及決定顯示哪個View頁面,即ASP.NET MVC中有關於『傳遞』的任務皆由Controller負責。Controller的執行階段負責呼叫執行Model中的資料處理,並把處理結果數據傳送到... 阅读全文
posted @ 2014-10-01 15:52 hishanghai 阅读(1189) 评论(0) 推荐(0) 编辑
摘要: 之前我們需要用到的數據,通過添加Entity實體數據模型把數據庫中需要的Database拉到項目中如下圖,而就是Code First就是相對於這種處理數據的方法而言的Code First更加準確的解讀是開發人員只需要編寫程式(Code Only),系統會自動建立模型和數據庫我們來新建一個專案看一下C... 阅读全文
posted @ 2014-08-27 12:21 hishanghai 阅读(1309) 评论(7) 推荐(1) 编辑
摘要: Model負責獲取數據庫中的資料,並對數據庫中的數據進行處理。MVC中有關 數據庫 的任務都由Model來完成,Model中對數據資料進行定義,Controller和View中都會參考到Model,從而對數據庫進行增刪改的操作。 Model不需要依賴Controller或是View,所以Model的... 阅读全文
posted @ 2014-08-25 16:56 hishanghai 阅读(1288) 评论(4) 推荐(0) 编辑
摘要: 新增專案實現留言板功能,瞭解MVC的運行機制1,新增專案 2,添加數據庫文件message.mdf Ctrl+W,L 打開資料庫連接,添加存放留言的Atricle表添加字段,後點擊"更新"後看到新增的Atricle表(Content 應該設置為text)3,添加ADO.NET實體數據模型 (MVC通... 阅读全文
posted @ 2014-08-21 13:33 hishanghai 阅读(2987) 评论(7) 推荐(1) 编辑
摘要: 1,方法多載,相同的方法名稱,不同的參數類型、數量class Program { static void Main(string[] args) { Program newObject = new Program(); /... 阅读全文
posted @ 2014-08-20 11:16 hishanghai 阅读(1643) 评论(4) 推荐(0) 编辑
摘要: protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse){//首先判断是否是数据行if(e.Row.RowType==DataControlRowType.DataRow){//当鼠标停留时更改背景色e.Row.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#C0C0C0'");//当鼠标移开时还原背景色e.Row.Attrib 阅读全文
posted @ 2012-09-24 00:12 hishanghai 阅读(168) 评论(0) 推荐(0) 编辑
摘要: http://www.microsoft.com/china/msdn/events/webcasts/shared/webcast/consyscourse/ASPNETpractise.aspx http://www.asp.net/web-forms/videos 阅读全文
posted @ 2012-09-17 23:49 hishanghai 阅读(117) 评论(0) 推荐(0) 编辑
摘要: ///<summary>///将DataTable数据导出到EXCEL,调用该方法后自动返回可下载的文件流///</summary>///<paramname="dtData">要导出的数据源</param>publicstaticvoidDataTable1Excel(System.Data.DataTabledtData){System.Web.UI.WebControls.GridViewgvExport=null;//当前对话System.Web.HttpContextcurContext=System.Web.Htt 阅读全文
posted @ 2012-09-15 12:19 hishanghai 阅读(683) 评论(0) 推荐(0) 编辑
摘要: protectedvoidDatatableExcelC(System.Data.DataTabledt){Microsoft.Office.Interop.Excel.Applicationexcelkccx=newMicrosoft.Office.Interop.Excel.ApplicationClass();Microsoft.Office.Interop.Excel._Workbookwb;Microsoft.Office.Interop.Excel._Worksheetws=null;wb=excelkccx.Workbooks.Add(true);stringtbname=&qu 阅读全文
posted @ 2012-09-15 11:11 hishanghai 阅读(229) 评论(0) 推荐(0) 编辑