如何以編程方式使用ASP.net GridView(即無數據綁定)?ASP.NET - GridView
0
A
回答
0
只需將DataSource屬性設置爲要顯示的對象,然後調用DataBind方法。
var items = new List<string> {"item1","item2","item3"};
GridView1.DataSource = items;
GridView1.DataBind();
0
沒有辦法像myGrid.Rows.Add()那樣訪問gridview的行。
您可以在將數據源綁定到您的gridview之前更新數據源。
1
我喜歡用數據表,所以我會做:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Include", typeof(Boolean));
dt.Columns.Add("Name", typeof(String));
dt.Rows.Add(new Object[] { 0, "Jim" });
dt.Rows.Add(new Object[] { 0, "Jen" });
dt.Rows.Add(new Object[] { 0, "Kylie" });
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
相關問題
- 1. asp.net gridview
- 2. gridview asp.net
- 3. Asp.net gridview
- 4. gridview asp.net
- 5. asp.net gridview
- 6. ASP.net Gridview
- 7. gridview asp.net
- 8. asp.net gridview
- 9. Asp.Net Gridview
- 10. asp.net C#Gridview嵌套gridview
- 11. Asp.net 4 Gridview Gridview驗證
- 12. asp.net gridview jquery contextmenu
- 13. GridView中的ASP.NET
- 14. 的ASP.NET的GridView
- 15. 關於ASP.NET Gridview
- 16. asp.net gridview pager hover
- 17. ASP.NET gridview刪除
- 18. asp.net gridview編輯
- 19. ASP.Net刷新GridView
- 20. ASP.NET XtraReports Gridview RowCellStyle
- 21. DropDownList與GridView ASP.NET
- 22. Asp.Net gridview定製
- 23. ASP.NET中的GRIDVIEW
- 24. ASP.NET GridView e.NewValues == e.OldValues
- 25. ASP.NET + GridView + Dynamic TemplateFields
- 26. ASP.NET GridView篩選
- 27. asp.net dropdownlist在gridview
- 28. asp.net gridview AjaxControlToolkit
- 29. ASP.NET的GridView SelectedRow
- 30. jquery,gridview,asp.net
-1他提到不使用數據綁定 – 2009-07-05 18:34:54