or
Here is my Code, Page_load method and RadGrid1_NeedDataSource.
The result is so weird, load in the 1 page, everything work find, when click next or 2nd page, the problem is occurs. The diagram show at Attach files.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RadGrid1.ID = "RadGrid1"
zzz.Controls.Add(RadGrid1)
AddHandler Me.RadGrid1.NeedDataSource, New GridNeedDataSourceEventHandler(AddressOf Me.RadGrid1_NeedDataSource)
RadGrid1.Visible = True
RadGrid1.AllowPaging = True
RadGrid1.AllowSorting = True
RadGrid1.AllowMultiRowSelection = True
RadGrid1.MasterTableView.AutoGenerateColumns = False
RadGrid1.PageSize = 5
RadGrid1.AutoGenerateColumns = False
RadGrid1.MasterTableView.EditMode = GridEditMode.Batch
RadGrid1.ClientSettings.Selecting.AllowRowSelect = True
RadGrid1.EnableViewState = False
RadAjaxManager1.EnableAJAX = True
End Sub
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
Dim ConnString As String = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString
Dim conn As SqlConnection = New SqlConnection(ConnString)
Dim adapter As SqlDataAdapter = New SqlDataAdapter
adapter.SelectCommand = New SqlCommand("SELECT * FROM Product", conn)
conn.Open()
Try
adapter.Fill(myDataTable)
Finally
conn.Close()
End Try
RadGrid1.DataSource = myDataTable
Dim boundColumn As GridBoundColumn
For Each col As System.Data.DataColumn In myDataTable.Columns
boundColumn = New GridBoundColumn()
RadGrid1.MasterTableView.Columns.Add(boundColumn)
boundColumn.DataField = col.ColumnName
boundColumn.HeaderText = col.ColumnName
If col.ColumnName = "proID" Then
'boundColumn.Visible = False
boundColumn.HeaderText = "ProductID"
ElseIf col.ColumnName = "proName" Then
boundColumn.HeaderText = "Product Name"
ElseIf col.ColumnName = "proQty" Then
boundColumn.HeaderText = "Product Quantity"
ElseIf col.ColumnName = "unitPrice" Then
boundColumn.HeaderText = "Price"
End If
Next
End Sub