This is a migrated thread and some comments may be shown as answers.
Editing RadGrid record
4 Answers 56 Views
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 22 Dec 2008, 04:26 PM
Hello All,

It is working fine in Development and once I publish it throws this error and it is not really telling me anything: 
sys.webforms.pagerequestmanagerservererrorexception: an unknown error occurred while processing the request on the server. the status code returned from the server was: 500
It was working fine in older version but when I upgraded to 2008.3 1125, it started throwing that error. I have tried 

EnableEventValidation

 

="false"  on the Main page; as the RadGrid is running on a user controler inside the Admin page here is the code and HTML of the user controler...

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PersonAdmin.ascx.vb" Inherits="PersonAdmin" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<script language="javascript" type="text/javascript">        
          Sys.Application.add_load(function()        
          {        
            var form = Sys.WebForms.PageRequestManager.getInstance()._form;        
            formform._initialAction = form.action = window.location.href;        
          });        
  </script>    
<table> 
    <tr> 
        <td style="width: 3px">  
        </td> 
        <td bgcolor="#ce9426">  
            <strong><span style="font-size: 10pt; color: white">Phone Personnal Admin</span></strong></td> 
    </tr> 
    <tr> 
        <td style="width: 3px">  
        </td> 
        <td> 
            <asp:Label ID="lblResult" runat="server" ForeColor="#C04000"></asp:Label></td>  
    </tr> 
    <tr> 
        <td style="width: 3px">  
        </td> 
        <td> 
            <telerik:RadGrid ID="rgPersonAdmin" runat="server" AllowSorting="True" 
                AutoGenerateColumns="False" GridLines="None" Skin="WebBlue" OnItemCommand="rgPersonAdmin_ItemCommand" OnPreRender="rgPersonAdmin_PreRender">  
                <MasterTableView CommandItemDisplay="Top" DataKeyNames="PersonID,PersonIndic,DepName,DepUniID,ContactUniID,RelationUniID">  
                    <Columns> 
                        <telerik:GridBoundColumn DataField="PersonID" Display="False" HeaderText="PersonID" 
                            ReadOnly="True" UniqueName="PersonID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="DepUniID" Display="False" HeaderText="DepUniID" 
                            ReadOnly="True" UniqueName="DepUniID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="ContactUniID" Display="False" HeaderText="ContactUniID" 
                            ReadOnly="True" UniqueName="ContactUniID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="RelationUniID" Display="False" HeaderText="RelationUniID" 
                            ReadOnly="True" UniqueName="RelationUniID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="ContactType" Display="False" HeaderText="ContactType" 
                            ReadOnly="True" UniqueName="ContactType">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn1">  
                        </telerik:GridEditCommandColumn> 
                        <telerik:GridTemplateColumn HeaderText="LastName" SortExpression="LastName" UniqueName="TemplateColumn">  
                            <ItemTemplate> 
                                <asp:Label ID="lblLastName" runat="server" Text='<%# Eval("LastName") %>'></asp:Label> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <asp:TextBox ID="tbLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox><span 
                                    style="color: Red">*</span> 
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbLastName" 
                                    ErrorMessage="This field is required">  
                                </asp:RequiredFieldValidator> 
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Ext" HeaderText="Ext" UniqueName="Ext">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Pager" HeaderText="Pager/Mobile" UniqueName="Pager">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridTemplateColumn DataField="DepName" HeaderText="Dep Name" UniqueName="DepName">  
                            <ItemTemplate> 
                                <asp:Label ID="lblDep" runat="server"></asp:Label> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <asp:DropDownList ID="DepNameddl" runat="server">  
                                </asp:DropDownList> 
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridBoundColumn DataField="Role" HeaderText="Role" UniqueName="Role">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridTemplateColumn AllowFiltering="False" DataField="PersonIndic" HeaderText="Active" 
                            UniqueName="PersonIndic">  
                            <ItemTemplate> 
                                <asp:CheckBox ID="cbPersonIndic" runat="server" Enabled="false" /> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <asp:CheckBox ID="PersonIndicCB" runat="server" Checked='<%# Bind("PersonIndic")%>' /> 
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                    </Columns> 
                    <RowIndicatorColumn Visible="False">  
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn Visible="False">  
                        <HeaderStyle Width="19px" /> 
                    </ExpandCollapseColumn> 
                </MasterTableView> 
            </telerik:RadGrid></td>  
    </tr> 
    <tr> 
        <td style="width: 3px">  
        </td> 
        <td> 
            <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="rgPersonAdmin">  
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="rgPersonAdmin" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                            <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManagerProxy> 
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Behavior="Maximize, Close, resize" 
                DestroyOnClose="True" Height="400px" Left="" MinimizeZoneID="HorizontalMinimize" 
                Modal="True" Title="" Top="" Width="600px">  
                <Windows> 
                    <telerik:RadWindow ID="RadWindow1" runat="server" Left="" NavigateUrl="RadPhys.aspx" 
                        Title="Physician Information" Top="">  
                    </telerik:RadWindow> 
                </Windows> 
            </telerik:RadWindowManager> 
            </td> 
    </tr> 
    <tr> 
        <td style="width: 3px">  
        </td> 
        <td> 
            <asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label></td>  
    </tr> 
</table> 
 
Imports System.Data  
Imports Telerik.Web.UI  
Imports System.Collections  
Imports System.Data.SqlClient  
Imports System.Web.UI  
Imports System.Web.UI.WebControls  
Imports System.Web.UI.WebControls.WebParts  
Imports System.Web.UI.HtmlControls  
Imports System.Security.Principal  
Imports AjaxControlToolkit  
Partial Class PersonAdmin  
    Inherits System.Web.UI.UserControl  
    Public dataConn As New PhoneBookDLL.dl  
 
    Shared shouldDisableCommandItem As Boolean = False 
    Shared shouldDisableEditItems As Boolean = False 
 
 
    Protected Sub rgPersonAdmin_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles rgPersonAdmin.Init  
        Dim menu As GridFilterMenu = rgPersonAdmin.FilterMenu  
        Dim i As Integer = 0  
        While i < menu.Items.Count  
            If menu.Items(i).Text = "NoFilter" Or menu.Items(i).Text = "Contains" Or menu.Items(i).Text = "EqualTo" Or menu.Items(i).Text = "StartsWith" Or _  
         menu.Items(i).Text = "EndsWith" Then 
                i = i + 1  
            Else 
                menu.Items.RemoveAt(i)  
            End If 
        End While 
    End Sub 
 
    Protected Sub rgPersonAdmin_InsertCommand1(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgPersonAdmin.InsertCommand  
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)  
            Dim strChk As String = item.GetDataKeyValue("PersonIndic").ToString()  
            Dim chkbx As CheckBox = DirectCast(item("PersonIndic").FindControl("cbPersonIndic"), CheckBox)  
            If strChk = "0" Then 
                chkbx.Checked = False 
            Else 
                chkbx.Checked = True 
            End If 
            Dim lbl As Label = DirectCast(item("DepName").FindControl("lblDep"), Label)  
            Dim DepNameDB As String = item.GetDataKeyValue("DepName").ToString()  
            If DepNameDB = System.DBNull.Value.ToString Then 
                lbl.Text = "" 
            Else : lbl.Text = DepNameDB  
            End If 
 
            Dim tbLastNamestr As TextBox = DirectCast(item("TemplateColumn").FindControl("tbLastName"), TextBox)  
            Dim LastNameDB As String = item.GetDataKeyValue("LastName").ToString()  
            If LastNameDB = System.DBNull.Value.ToString Then 
                tbLastNamestr.Text = "" 
            Else : tbLastNamestr.Text = LastNameDB  
            End If 
 
        End If 
        Dim insertedItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)  
        'Dim LastName As String = (TryCast(insertedItem("LastName").Controls(0), TextBox)).Text  
        Dim tbLastName As TextBox = DirectCast(insertedItem("TemplateColumn").FindControl("tbLastName"), TextBox)  
        Dim LastName As String = tbLastName.Text  
 
        Dim FirstName As String = (TryCast(insertedItem("FirstName").Controls(0), TextBox)).Text  
        Dim EmployeeID As String = (TryCast(insertedItem("EmployeeID").Controls(0), TextBox)).Text  
        Dim Ext As String = (TryCast(insertedItem("Ext").Controls(0), TextBox)).Text  
        Dim Pager As String = (TryCast(insertedItem("Pager").Controls(0), TextBox)).Text  
        Dim Office As String = (TryCast(insertedItem("Office").Controls(0), TextBox)).Text  
        Dim Fax As String = (TryCast(insertedItem("Fax").Controls(0), TextBox)).Text  
        Dim IP As String = (TryCast(insertedItem("IP").Controls(0), TextBox)).Text  
 
        Dim chkbx1 As CheckBox = DirectCast(insertedItem("PersonIndic").FindControl("PersonIndicCB"), CheckBox)  
        Dim Indic As Integer 
        If chkbx1.Checked = True Then 
            Indic = 1  
        Else 
            Indic = 0  
        End If 
 
        Dim ddlbx As DropDownList = DirectCast(insertedItem("DepName").FindControl("DepNameddl"), DropDownList)  
        Dim DepUniID As Integer 
        DepUniID = ddlbx.SelectedValue  
 
        Dim Role As String = (TryCast(insertedItem("Role").Controls(0), TextBox)).Text  
 
        Dim u As String = My.User.Name  
        Dim c As String = My.Computer.Name  
 
        Dim PersonID, result As Integer 
        PersonID = dataConn.PhoneInsPerson(LastName, FirstName, EmployeeID, Indic, u, c)  
 
        If PersonID <> -1 Then 
            result = dataConn.PhoneInsContact(2, PersonID, Ext, Pager, Office, Fax, "", IP, u, c)  
            result = result - dataConn.PhoneInsDepRel(DepUniID, PersonID, 2, 1, Role, u, c)  
        End If 
 
    End Sub 
 
    Protected Sub rgPersonAdmin_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgPersonAdmin.ItemCommand  
        If (e.CommandName = RadGrid.InitInsertCommandName) Then 
            'cancel the default operation  
            e.Canceled = True 
 
            'Prepare an IDictionary with the predefined values  
            Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()  
            '' ''newValues("ContactName") = "default contact name"  
            '' ''newValues("CompanyName") = " default company name"  
 
            'set default value for the dropdown list inside the EditItemTemplate  
            newValues("DepUniID") = "1" 
            'set default checked state for checkbox inside the EditItemTemplate  
            newValues("PersonIndic") = "1" 
 
            'Insert the item and rebind  
            e.Item.OwnerTableView.InsertItem(newValues)  
        End If 
 
        If e.CommandName = RadGrid.EditCommandName Then 
            shouldDisableCommandItem = True 
        ElseIf e.CommandName = RadGrid.InitInsertCommandName Then 
            shouldDisableEditItems = True 
            'ElseIf e.CommandName = RadGrid.CancelCommandName Then  
        Else 
            shouldDisableCommandItem = False 
            shouldDisableEditItems = False 
        End If 
    End Sub 
 
    Protected Sub rgPersonAdmin_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgPersonAdmin.ItemDataBound  
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)  
            Dim strChk As String = item.GetDataKeyValue("PersonIndic").ToString()  
            Dim chkbx As CheckBox = DirectCast(item("PersonIndic").FindControl("cbPersonIndic"), CheckBox)  
            If strChk = "0" Then 
                chkbx.Checked = False 
            Else 
                chkbx.Checked = True 
            End If 
            Dim lbl As Label = DirectCast(item("DepName").FindControl("lblDep"), Label)  
            Dim DepNameDB As String = item.GetDataKeyValue("DepName").ToString()  
            If DepNameDB = System.DBNull.Value.ToString Then 
                lbl.Text = "" 
                Label1.Text = "0" 
            Else 
                lbl.Text = DepNameDB  
                Label1.Text = CType(item.GetDataKeyValue("DepUniID"), String)  
            End If 
        End If 
        'dropdownlist  
        If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then 
            Dim edititem As GridEditableItem = DirectCast(e.Item, GridEditableItem)  
            Dim ddl As DropDownList = DirectCast(edititem("DepName").FindControl("DepNameddl"), DropDownList)  
            Dim getDS As New DataSet  
            getDS = dataConn.PhoneGetDepDDL()  
            ddl.DataSource = getDS.Tables(0).DefaultView  
            ddl.DataTextField = "DepName" 
            ddl.DataValueField = "DepID" 
            ddl.DataBind()  
 
            Dim chosen As String 
            chosen = Label1.Text  
            If chosen = System.DBNull.Value.ToString Or chosen = 0 Then 
                ddl.SelectedValue = 0  
            Else 
                ddl.SelectedValue = chosen  
            End If 
        End If 
    End Sub 
 
    Protected Sub rgPersonAdmin_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgPersonAdmin.NeedDataSource  
        Dim getDS As New DataSet  
        getDS = dataConn.PhoneAllPerson()  
        rgPersonAdmin.DataSource = getDS.Tables(0).DefaultView  
    End Sub 
 
    Protected Sub rgPersonAdmin_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles rgPersonAdmin.PreRender  
        If shouldDisableEditItems Then 
            For Each dataItem As GridDataItem In rgPersonAdmin.MasterTableView.Items  
                TryCast(dataItem("EditCommandColumn1").Controls(0), LinkButton).Enabled = False 
            Next 
        ElseIf shouldDisableCommandItem Then 
            Dim commandItem As GridCommandItem = DirectCast(rgPersonAdmin.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)  
            commandItem.Enabled = False 
        End If 
    End Sub 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        Page.Title = "Phonebook Personnel Admin" 
    End Sub 
 
    Protected Sub rgPersonAdmin_UpdateCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgPersonAdmin.UpdateCommand  
        Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)  
 
        Dim strPersonID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("PersonID").ToString()  
        Dim PersonID As Integer = CType(strPersonID, Integer)  
 
        Dim RelationUniID  
        Dim strRelationUniID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("RelationUniID").ToString()  
        If strRelationUniID = "" Then 
            RelationUniID = "0" 
        Else : RelationUniID = CType(strRelationUniID, Integer)  
        End If 
 
        Dim strContactUniID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("ContactUniID").ToString()  
        Dim ContactUniID As Integer = CType(strContactUniID, Integer)  
 
        'Dim LastName As String = (TryCast(editedItem("LastName").Controls(0), TextBox)).Text  
        Dim tbLastName As TextBox = DirectCast(editedItem("TemplateColumn").FindControl("tbLastName"), TextBox)  
        Dim LastName As String = tbLastName.Text  
 
        Dim FirstName As String = (TryCast(editedItem("FirstName").Controls(0), TextBox)).Text  
        Dim EmployeeID As String = (TryCast(editedItem("EmployeeID").Controls(0), TextBox)).Text  
        Dim Ext As String = (TryCast(editedItem("Ext").Controls(0), TextBox)).Text  
        Dim Pager As String = (TryCast(editedItem("Pager").Controls(0), TextBox)).Text  
        Dim Office As String = (TryCast(editedItem("Office").Controls(0), TextBox)).Text  
        Dim Fax As String = (TryCast(editedItem("Fax").Controls(0), TextBox)).Text  
        Dim IP As String = (TryCast(editedItem("IP").Controls(0), TextBox)).Text  
 
        'Dim DepName As String = (TryCast(editedItem("DepName").Controls(0), TextBox)).Text  
 
        Dim Role As String = (TryCast(editedItem("Role").Controls(0), TextBox)).Text  
 
        Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)  
        Dim chkbx As CheckBox = DirectCast(item("PersonIndic").FindControl("PersonIndicCB"), CheckBox)  
        Dim Indic As Integer 
        If chkbx.Checked = True Then 
            Indic = 1  
        Else 
            Indic = 0  
        End If 
 
        Dim ddlbx As DropDownList = DirectCast(item("DepName").FindControl("DepNameddl"), DropDownList)  
        Dim DepUniID As Integer 
        DepUniID = ddlbx.SelectedValue  
 
        Dim u As String = My.User.Name  
        Dim c As String = My.Computer.Name  
 
        Dim PersonIndic As String = CType(Indic, String)  
        Dim confirm As Integer 
        confirm = dataConn.PhoneEditPerson(PersonID, DepUniID, ContactUniID, LastName, FirstName, EmployeeID, Ext, Pager, Office, Fax, IP, PersonIndic, Role, RelationUniID, u, c)  
 
        Dim commandItem As GridCommandItem = DirectCast(rgPersonAdmin.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)  
        commandItem.Enabled = True 
    End Sub 
End Class 
 

Thank you for all your help...
Shehab

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Dec 2008, 09:02 AM
Hello Shehab,

As a starting point I suggest you examine the following blog post:
Web Resources demystified: Part 3 (Troubleshooting)

Let us know whether this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shehab
Top achievements
Rank 1
answered on 24 Dec 2008, 06:04 PM
Hello Daniel,

Thank you very much for your respond; I still can't find any solution for my issue in the blog... It is working fine on my machine but when I publish it pops up this error.

Thank you,
Shehab
0
Lydia
Top achievements
Rank 1
answered on 20 Mar 2014, 07:19 AM
Hi, I got the same issue now, did you remember whether you manage to solve it?
and if so, how to solve it?
Thanks.
0
Daniel
Telerik team
answered on 25 Mar 2014, 08:06 AM
Hello,

The link to the blog post below is no longer valid. Here is the correct one:
Web Resources demystified: Part 3 (Troubleshooting)

Regards,
Daniel
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Ajax
Asked by
Shehab
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shehab
Top achievements
Rank 1
Lydia
Top achievements
Rank 1
Share this question
or