This is a migrated thread and some comments may be shown as answers.

[Solved] Error in Telerik Dynamic Code

4 Answers 128 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 03 May 2013, 05:56 PM
I have a radgrid in which I am using a custom edit form. When I do anything on the edit form I am getting the error in the screenshot attached to this post. Below is the code for my edit form control and code behind of the custom edit form control.

Custom Edit Form Control UI Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditSCAC.ascx.cs" Inherits="EditSCAC" %>
<telerik:RadAjaxManager ID="radAjaxMgr" runat="server" UpdatePanelsRenderMode="Inline">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="scacGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="scacTypeDDL" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div>
    <table id="scacEditTable">
        <tr>
            <td>
                <table>
                    <tr>
                        <td>
                            <asp:Label runat="server">SCAC:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scacTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC") %>'></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label runat="server">SCAC DESCRIPTION:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scacDescTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC_DESC") %>'></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label runat="server">SCAC PHONE:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scaPhoneTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC_PHONE") %>'></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label runat="server">SCAC TYPE:</asp:Label>
                        </td>
                        <td>
                            <telerik:RadComboBox ID="scacTypeDDL" AutoPostBack="True" runat="server" EmptyMessage="Please choose a type...">
                            </telerik:RadComboBox>
                        </td>
                        <td>
                            <asp:Label runat="server">CONTACT:</asp:Label>
                        </td>
                        <td>
                            <telerik:RadComboBox ID="contactDDL" AutoPostBack="True" runat="server" EmptyMessage="Please choose a contact...">
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is GridInsertionObject) %>'
                                CausesValidation="true" ValidationGroup="FormValidationGroup"></asp:Button>
                            <asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="PerformInsert"
                                Visible='<%# (DataItem is GridInsertionObject) %>' CausesValidation="true" ValidationGroup="FormValidationGroup">
                            </asp:Button>
                              
                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel"></asp:Button>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>


Custom Edit Form Control Code Behind:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using Telerik.Web.UI;
 
namespace IRRIS.Site.DTTS
{
    public partial class EditSCAC : System.Web.UI.UserControl
    {
        public object DataItem { get; set; }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            Populate_SCACDDL();
            Populate_ContactsDDL();
        }
 
        protected void Populate_SCACDDL()
        {
            var ds = new DataSet();
            var factory = new QueryFactory(new Configuration().DataConfigurationFile);
            var query = factory.GetQuery("P_GET_SCAC_TYPES");
            query.Fill(ds);
 
            var list = new List<string>();
            var dt = ds.Tables[0];
            list = (from dr in dt.AsEnumerable()
                    select dr.Field<string>("LUVALUE")).ToList<string>();
 
            scacTypeDDL.DataTextField = ds.Tables[0].Columns["LUDESCRIPTION"].ToString();
            scacTypeDDL.DataValueField = ds.Tables[0].Columns[1].ToString();
            scacTypeDDL.DataSource = ds.Tables[0];
 
            var scacTypeDdlValue = String.Empty;
             
            if (DataItem != null)
            {
                scacTypeDdlValue = DataBinder.Eval(DataItem, "SCAC_TYPE").ToString();
                if (!list.Contains(scacTypeDdlValue))
                {
                    scacTypeDDL.SelectedIndex = -1;
                }
                else
                {
                    scacTypeDDL.SelectedValue = scacTypeDdlValue;
                }
            }
        }
 
        protected void Populate_ContactsDDL()
        {
            var ds = new DataSet();
            var factory = new QueryFactory(new Configuration().DataConfigurationFile);
            var query = factory.GetQuery("P_GET_ALL_CONTACTS");
            query.Fill(ds);
 
            var list = new List<string>();
            var dt = ds.Tables[0];
            list = (from dr in dt.AsEnumerable()
                    select Convert.ToString(dr.Field<decimal>("CONTACT_ID"))).ToList<string>();
 
            contactDDL.DataTextField = ds.Tables[0].Columns["CONTACT_ORG"].ToString();
            contactDDL.DataValueField = ds.Tables[0].Columns[0].ToString();
            contactDDL.DataSource = ds.Tables[0];
 
            var contactDdlValue = String.Empty;
             
            if (DataItem != null)
            {
                contactDdlValue = DataBinder.Eval(DataItem, "SCAC_CONTACT_ID").ToString();
                if (!list.Contains(contactDdlValue))
                {
                    contactDDL.SelectedIndex = -1;
                }
                else
                {
                    contactDDL.SelectedValue = contactDdlValue;
                }
            }
        }
    }
}


Any ideas what could be causing this error?

4 Answers, 1 is accepted

Sort by
0
Anna
Top achievements
Rank 1
answered on 04 May 2013, 12:58 PM
It seems that there is nothing wrong with the Radgrid that you are using in your code. Is there any other option for Radgrid ?
0
Anna
Top achievements
Rank 1
answered on 06 May 2013, 01:25 PM
How many types of Radgrid controls are available in Asp.Net ?
0
John
Top achievements
Rank 1
answered on 06 May 2013, 01:29 PM
Telerik,

Any ideas what is causing this error?
0
Eyup
Telerik team
answered on 08 May 2013, 10:12 AM
Hi John,

Please note that in a complex scenario like WebUserControls or Master/ContentPages, you should place RadAjaxManager instance on the main/master page and add a proxy control to the user control/content page. Furthermore, you will need to add the grid as an UpdatedControl in the AjaxSettings.

Additionally, you can check out the following example which demonstrates updating RadGrid with a WebUserControl:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

Hope this helps. If the issue remains, please provide us the exact steps to reproduce the issue or open a support ticket to send us a sample runnable application demonstrating the erratic behavior. Thus, we will be able to further analyze the problem and provide a proper solution.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Anna
Top achievements
Rank 1
John
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or