Good Afternoon all,
I am hoping to get some help with a simple grid setup that I am working on. I am researching how the Rad Grid control works in order to use it in our production environment. I have little knowledge of the control or its interworkings. I've read through the online documentation and have tried to recreate the example demo with focus toward how I would use it in production. I have a basic Dataset whichi I populate manually for my example. On the aspx page i'm using a basic RadGrid and set the OnNeedDatatSource, I set the MasterTableView EditMode to InPlace and have the columns auto generated. The issue i am seeing is when i click the edit button the RadGrid1_ItemCreated Event is fired but none of theobjects coming in are of type GridDataInsertItem and the IsInEditMode property is always false resulting in a grid that only display "No Records to Display". I'm not sure what i'm missing. Any help would be appreciated. My code is below:
ASPX
Code Behind:
I am hoping to get some help with a simple grid setup that I am working on. I am researching how the Rad Grid control works in order to use it in our production environment. I have little knowledge of the control or its interworkings. I've read through the online documentation and have tried to recreate the example demo with focus toward how I would use it in production. I have a basic Dataset whichi I populate manually for my example. On the aspx page i'm using a basic RadGrid and set the OnNeedDatatSource, I set the MasterTableView EditMode to InPlace and have the columns auto generated. The issue i am seeing is when i click the edit button the RadGrid1_ItemCreated Event is fired but none of theobjects coming in are of type GridDataInsertItem and the IsInEditMode property is always false resulting in a grid that only display "No Records to Display". I'm not sure what i'm missing. Any help would be appreciated. My code is below:
ASPX
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TelerikGridControlProject._Default" %> <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js"> </asp:ScriptReference> </Scripts> </telerik:RadScriptManager> <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource" Visible="true"> <MasterTableView EditMode="InPlace" AutoGenerateColumns="True" Visible="true"> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" /> </Columns> </MasterTableView> </telerik:RadGrid> </asp:Content>Code Behind:
Imports Telerik.Web.UI Public Class _Default Inherits System.Web.UI.Page Private _myDataTable As New DataTable Private _nameColumn As DataColumn Private _myObjectDataSource As ObjectDataSource Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then BuildDataTable() FillDataTable() End If End Sub Private Sub FillDataTable() Dim dataRow As DataRow For i As Integer = 0 To 1 dataRow = MyDataTable.NewRow() dataRow("CIFNUMBER") = 1 dataRow("CustomerName") = String.Format("Customer {0}", i) dataRow("BusinessType") = String.Format("Business {0}", i) dataRow("Role") = "Role" dataRow("RelationshipToPrimary") = "Spouse" dataRow("VotingRights") = i dataRow("Scored") = i * 100 MyDataTable.Rows.Add(dataRow) Next End Sub Private Sub BuildDataTable() Dim nameList As List(Of String) = New List(Of String)(New String() {"CIFNUMBER", "CustomerName", "BusinessType", "Role", "RelationshipToPrimary", "VotingRights", "Scored"}) For i As Integer = 0 To nameList.Count - 1 MyDataTable.Columns.Add(i) MyDataTable.Columns.Add(nameList(i)) Next End Sub Public Property MyDataTable As DataTable Get Return _myDataTable End Get Set(value As DataTable) _myDataTable = value End Set End Property Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = MyDataTable End Sub Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated If (TypeOf e.Item Is GridDataInsertItem AndAlso e.Item.IsInEditMode) Then 'init insert operation triggered Dim myString As String = "NOTHING" ElseIf (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then 'edit operation triggered Dim myString As String = "NOTHING" End If End Sub End Class