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

Grid Edit Command doesnt work

2 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josue
Top achievements
Rank 1
Josue asked on 10 Feb 2011, 10:32 PM
Hi,

Recently have been working with the trial version of RadControls for ASP.NET Ajax Q3 2010, downloaded from here...
And after trying to test some demos, i can't get to work with the grideditcommand, so here is my code

Users.aspx
<%@ Page Title="Users | Telerik Trial Testing" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="TelerikTrial.Users" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadComboBox ID="App_List" runat="server" AutoPostBack="true" DataTextField="ApplicationName"
        DataValueField="LoweredApplicationName" OnSelectedIndexChanged="App_List_SelectedIndexChanged">
    </telerik:RadComboBox>
    <br />
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="App_List">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="App_List" />
                    <telerik:AjaxUpdatedControl ControlID="User_List" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="User_List">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="App_List" />
                    <telerik:AjaxUpdatedControl ControlID="User_List" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadGrid ID="User_List" runat="server" AllowPaging="True"
        AutoGenerateColumns="False" GridLines="None"
        Skin="Windows7" OnPageIndexChanged="User_List_PageIndexChanged">
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
        <MasterTableView EditMode="PopUp" CommandItemDisplay="Top" DataKeyNames="UserName">
            <EditFormSettings InsertCaption="Add new user" CaptionFormatString="Edit User: {0}"
                CaptionDataField="UserName" PopUpSettings-Modal="true" />
            <Columns>
                <telerik:GridEditCommandColumn />
                <telerik:GridClientDeleteColumn />
                <telerik:GridBoundColumn DataField="UserName" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="Email" />
                <telerik:GridBoundColumn DataField="LastLoginDate" ReadOnly="true" />
                <telerik:GridCheckBoxColumn DataField="IsLockedOut" />
            </Columns>
        </MasterTableView>
         <ClientSettings>
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
    </telerik:RadGrid>
</asp:Content>

Site.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.Master.cs" Inherits="TelerikTrial.Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
    </asp:ContentPlaceHolder>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/Common/Core.js" />
            <asp:ScriptReference Path="~/Scripts/Common/jQuery.js" />
            <asp:ScriptReference Path="~/Scripts/Common/jQueryInclude.js" />
            <asp:ScriptReference Path="~/Scripts/Ajax/Ajax.js" />
            <asp:ScriptReference Path="~/Scripts/XmlHttpPanel/RadXmlHttpPanel.js" />
            <asp:ScriptReference Path="~/Scripts/Grid/RadGridScripts.js" />
            <asp:ScriptReference Path="~/Scripts/ComboBox/RadComboBoxScripts.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    Telerik Trial
                </h1>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
                    IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Default" />
                        <asp:MenuItem NavigateUrl="~/Users.aspx" Text="Users" />
                    </Items>
                </asp:Menu>
            </div>
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
    </div>
    </form>
</body>
</html>

Users.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace TelerikTrial
{
    public partial class Users : System.Web.UI.Page
    {
        private void Bind_User_List(String AppName = "default")
        {
            if (ViewState["AppName"] != null)
                AppName = (String)ViewState["AppName"];
 
            User_List.DataSource = new DataProvider().ObtainAllMembershipAPIUsers(AppName); // Returns a Dataset from a sql server 2k8 stored procedure...
            User_List.DataBind();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                App_List.DataSource = new DataProvider().ObtenerTodasLasAplicaciones();
                App_List.DataBind();
                this.Bind_User_List();
                ViewState["AppName"] = App_List.SelectedItem.Value;
            }
        }
 
        protected void App_List_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            ViewState["AppName"] = App_List.SelectedItem.Value;
            User_List.CurrentPageIndex = 0;
            this.Bind_User_List();
        }
 
        protected void User_List_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        {
            User_List.CurrentPageIndex = e.NewPageIndex;
            this.Bind_User_List();
        }
 
    }
}

As you can see is pretty basic webapp... is a grid ajaxfied, etc...
So ok, everything works fine until i hit edit, when i hit it it will then "fail" and only show an a empty grid:

http://img441.imageshack.us/img441/4199/ss20110210152701.png

M guessing is expecting another databind but i dont know on what event attach and the documentation provided online http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/popupeditform/defaultcs.aspx isnt very helpful...
Hope you can answer my question and sorry to bother you m just trial testing your product to see if its fits my own coding style and of course if it really helps, so far is great the skinning, the touch-less? ajax but the documentation is very poor (uber poor), sometimes it fills to have more steps to achieve the very basic which in the original components it will just take 1 or 2...

Best Regards


2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 14 Feb 2011, 12:26 PM
Hi Josue,

Simple data-binding can be used in simple cases when you do not require the grid to perform complex operations such as
  • Inserting, deleting, and updating records through custom edit forms (WebUserControl or FormTemplate)
  • Grouping
  • Hierarchy relations
  • Filtering
  • Sorting
  • Paging
For advanced features such as those listed above, RadGrid must be bound using declarative data sources or through the NeedDataSource event.

I hope this helps.

Best wishes,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Josue
Top achievements
Rank 1
answered on 22 Feb 2011, 04:19 AM
Thanks i figure out after some debugging sessions but i forgot to came here...
I used the NeedDataSource Event but first i modify my function Bind_User_List() so it can just set the source without binding the data to the grid.

Best Regards.
Tags
Grid
Asked by
Josue
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Josue
Top achievements
Rank 1
Share this question
or