GridView 控制項事件發生順序

來源:互聯網
上載者:User

    

     GridView控制項第一觸發的事件為Init事件,即初始化控制項,隨後是Load事件,把控制項載入到頁面中。如裡載入控制項成功,則開始執行資料繫結的操作,並且在資料繫結過程中建立控制項的每一行。建立控制項的所有行這後,在頁面上呈現控制項,從而完成控制項在頁面上呈現的過程。

一、GridView 顯示繫結資料(預設為5行):

DataBinding
RowCreated:Header[0]
RowDataBound
RowCreated:DataRow[1]
RowDataBound
RowCreated:DataRow[2]
RowDataBound
RowCreated:DataRow[3]
RowDataBound
RowCreated:DataRow[4]
RowDataBound
RowCreated:DataRow[5]
RowDataBound
RowCreated:Footer[6] //不管有沒有頁角行,該事件都會發生
RowDataBound
RowCreated:Pager[7]
RowDataBound
DataBound

順序如下:

DataBinding
RowCreated
RowDataBound
......
DataBound

二、GridView 點擊分頁按鈕時的事件發生順序:

RowCommand
PageIndexChanging
PageIndexChanged
DataBinding
RowCreated:Header[8]
RowDataBound
RowCreated:DataRow[9]
RowDataBound
RowCreated:DataRow[10]
RowDataBound
RowCreated:DataRow[11]
RowDataBound
RowCreated:DataRow[12]
RowDataBound
RowCreated:DataRow[13]
RowDataBound
RowCreated:Footer[14]
RowDataBound
RowCreated:Pager[15]
RowDataBound
DataBound

總結:

      在 GridView 綁定資料開始,也就是觸發 DataBounding 事件後,這時已經把資料從資料來源取出或者說已經規定了那些資料欄位將會被取出,其中 的 Visible 屬性為 false 的欄位的值是不會從資料來源中擷取的。這就是為什麼當 GridView 使用直接在 html 中將 Visible=false 來隱藏某一列時,會得不到該列的值。然後調用 RowCreated 事件把一行資料全部填充到一個 gridViewRow 裡面,然後觸發 RowDataBound 事件把該行綁定到 GridView 的 Rows 中。一直到最後觸發 GridView 的 DataBound 來綁定顯示資料。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.