有人能告訴我如何檢索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. 文本框的值編輯的GridView
- 3. 編輯gridview單元格的文本框?
- 4. asp.net gridview編輯
- 5. ASP.NET GridView編輯
- 6. 調整GridView編輯文本框大小
- 7. 編輯GridView的文本
- 8. Asp.net 2.0 Gridview編輯
- 9. ASP.NET編輯GridView行
- 10. ASP.NET將jquery日期選擇器添加到Gridview文本框(編輯gridview)
- 11. asp.net gridview文本框值
- 12. 自動完成文本框上的GridView編輯
- 13. Asp.net gridview編輯沒有編輯按鈕
- 14. Gridview編輯後排序ASP.NET
- 15. asp.net可編輯的GridView - 設置標題文本顏色
- 16. asp.net gridview的編輯模板編程
- 17. 在我的GridView中顯示可編輯的文本框
- 18. ASP.Net gridview AutoGenerateColumns =「true」樣式和格式文本框在編輯時在行中
- 19. 編輯,刪除和更新與驗證和文本框的gridview
- 20. GridView的可編輯文本框在Chrome中不工作
- 21. GridView如何從編輯中的文本框中獲取值MDOE
- 22. 文本編輯器 - Asp.net mvc
- 23. 編輯文本框沒有被編輯
- 24. GridView的templatefield文本框和AutoCompleteExtender ASP.NET
- 25. ASP.NET GridView的RowCommand文本框空
- 26. ASP.NET GridView的文本框問題
- 27. ASP.NET的GridView的所有記錄編輯
- 28. 編輯ASP.NET中的XML Gridview的函數
- 29. 無法在GridView中識別文本框編輯項目模板
- 30. Gridview編輯模式不會修改文本框屬性
不要忘記將答案標記爲接受, – 2011-06-01 19:23:11