有人能告訴我如何檢索asp.net c#中的gridview中的文本框嗎?我有一堆數據顯示在gridview中,我希望它是可編輯的。我已經添加了一個編輯命令字段,它給了我這個編輯鏈接。當我按下這個鏈接時,會出現一個文本框,但是我如何獲得該文本框的引用,以便可以在調用行更新處理程序之前獲取文本框內的任何內容並對其進行更改?在GridView中的你rowedit事件ASP.NET Gridview的編輯文本框
2
A
回答
1
。利用FindControl
的方法來找到你想要的文本框......
是
void AuthorsGridView_RowUpdating (Object sender, GridViewUpdateEventArgs e)
{
// The GridView control does not automatically extract updated values
// from TemplateField column fields. These values must be added manually
// to the NewValues dictionary.
// Get the GridViewRow object that represents the row being edited
// from the Rows collection of the GridView control.
int index = AuthorsGridView.EditIndex;
GridViewRow row = AuthorsGridView.Rows[index];
// Get the controls that contain the updated values. In this
// example, the updated values are contained in the TextBox
// controls declared in the edit item templates of each TemplateField
// column fields in the GridView control.
TextBox lastName = (TextBox)row.FindControl("LastNameTextBox");
TextBox firstName = (TextBox)row.FindControl("FirstNameTextBox");
}
0
您可以通過了解在GridView訪問一個元素它位於RowIndex
之內並且元素名稱"text_textbox"
TextBox text = ((TextBox)contacts.Rows[RowIndex].FindControl("text_textbox")).Text;
相關問題
- 1. Gridview文本框編輯
- 2. ASP.NET GridView編輯
- 3. asp.net gridview編輯
- 4. 調整GridView編輯文本框大小
- 5. Asp.net 2.0 Gridview編輯
- 6. ASP.NET編輯GridView行
- 7. ASP.NET將jquery日期選擇器添加到Gridview文本框(編輯gridview)
- 8. 自動完成文本框上的GridView編輯
- 9. asp.net gridview文本框值
- 10. Gridview編輯後排序ASP.NET
- 11. asp.net gridview的編輯模板編程
- 12. 編輯,刪除和更新與驗證和文本框的gridview
- 13. ASP.Net gridview AutoGenerateColumns =「true」樣式和格式文本框在編輯時在行中
- 14. ASP.NET GridView的文本框問題
- 15. ASP.NET GridView的RowCommand文本框空
- 16. 文本編輯器 - Asp.net mvc
- 17. 編輯ASP.NET中的XML Gridview的函數
- 18. ASP.NET的GridView的所有記錄編輯
- 19. Gridview BoundField編輯文本框啓用多行
- 20. 無法在GridView中識別文本框編輯項目模板
- 21. 如何把文本框和Dropdownlist在GridView中進行編輯?
- 22. 可編輯文本框
- 23. 編輯一個GridView列的代碼asp.net
- 24. Asp.net MVC GridView的編輯列選項
- 25. asp.net gridview的編輯模板http鏈接
- 26. 動態編輯文本和文本框
- 27. 編輯運行時asp.net中的列表框選擇的文本
- 28. GridView行不更新,從GridView中的文本框中的文本編輯模板不來
- 29. 編輯ASP.Net MVC應用程序不工作的文本框?
- 30. ASP.NET GridView - 編輯動態模板列
不要忘記將答案標記爲接受, – 2011-06-01 19:23:11