[.NET] GridView的編輯按鈕怎執行?

作者: renmax (竹科學友哥)   2016-02-16 15:12:06
請輸入專案類型(網站專案或者應用程式專案):VB.net VS2015
各位版友好
最近剛好在實作GridView相關,在.aspx檔內已增加
<asp:GridView ID="GridView1" ...... AutoGenerateEditButton="True" ...... >
.vb內也已增加以下code
Protected Sub GridView1_RowUpdating(......) Handles GridView1.RowUpdating
......
Dim ck As CheckBox =
CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(0), CheckBox)
......
End Sub
現在除了上述CheckBox的功能外,想新增可以修改文字Cells(1)內容的功能
意思就是按下"編輯"按鈕後,可以一次執行CheckBox和修改文字的兩種功能
有想過直接加上
Dim tb As TextBox =
CType(GridView1.Rows(e.RowIndex).Cells(1).Controls(0), TextBox)
但會出現錯誤,卻不知道原因是什麼@@"
爬過相關文章,好像可以使用RowEditing事件
但"編輯"這按鈕該怎麼判斷是執行RowUpdating或RowEditing呢?
謝謝
作者: ian90911 (xopowo)   2016-02-17 13:18:00
rowediting好像是是rowcommand=edit觸發CommandName="Edit" CommandName="Update"按下編輯前是ItemTemplate 按下後是EditItemTemplate
作者: JohnYaEPen (醬也一篇)   2016-02-19 08:23:00
出現什麼錯誤訊息
作者: renmax (竹科學友哥)   2016-02-19 17:01:00
已找到方法 原因是將ReadOnly="false"即可 謝謝

Links booklink

Contact Us: admin [ a t ] ucptt.com