0
我遇到了VS2013中的Gridview控件問題。我有一個帶有GridView的簡單頁面,可以加載200條記錄。我需要能夠編輯第一個&姓氏,以便它們位於TemplateFields中。當我在IE11中打開頁面時,該頁面在Gridview中顯示記錄,但該頁面在幾分鐘內基本無響應。如果我嘗試向下滾動滾動條,只需坐在那裏10秒鐘,然後稍微移動一下。如果頁面上有其他鏈接,則它們不起作用,甚至關閉Web瀏覽器也需要一段時間。我已經在Firefox和Chrome中嘗試了這一點,並且具有相同的問題,儘管不太明顯。我在VS2010中創建了完全相同的項目,並且具有完全相同的代碼的頁面正常工作。有誰知道爲什麼會發生這種情況。VS2013 Gridview問題
HTML代碼:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:TemplateField HeaderText="First">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
後面的代碼:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
LoadGrid()
End If
End Sub
Public Sub LoadGrid()
Dim dt As DataTable
Dim dr As DataRow
dt = New DataTable
dt.Columns.Add("ID", GetType(String))
dt.Columns.Add("FirstName", GetType(String))
dt.Columns.Add("LastName", GetType(String))
Dim i As Integer = 0
For i = 0 To 200
dr = dt.NewRow
dr(0) = i
dr(1) = "John" & i.ToString
dr(2) = "Doe" & i.ToString
dt.Rows.Add(dr)
Next
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
End Class