RadGrid TemlateColumn OnRowDataBound

2 posts, 0 answers
  1. Chandan Dey
    Chandan Dey avatar
    50 posts
    Member since:
    Aug 2012

    Posted 12 Apr 2014 Link to this post


    While accessing control which is present in item template, from “OnRowDataBound” client event, it seems that after returning 11th items, it could not able to find rest of the items.

    I am wondering why It could not found control in item template after 11th items and started returning null.

    I have attached sample project for your reference
    Please refer the following function in sample project.

    function onGridRowBound(sender, args) {
           cnt++; var btn = args.get_item().findElement("RadTextBox1");
     btn.value = args.get_dataItem().Text;

    Once “cnt” is greater than 11, suddenly it stared returns null of "btn" reference.

    I have add my code here,

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <script type="text/javascript">
    function pageLoad() {
    var data = [{ Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }];
    var mtv = $find('<%=RadGrid1.ClientID %>').get_masterTableView();
    function gridCommand(sender, args) {
    var cnt = 0;
    function onGridRowBound(sender, args) {

    var btn = args.get_item().findElement("RadTextBox1");
    btn.value = args.get_dataItem().Text;
    <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false">
    <telerik:GridTemplateColumn DataField="Text">
    <telerik:RadTextBox ID="RadTextBox1" runat="server"/>
    <ClientEvents OnCommand="gridCommand" OnRowDataBound="onGridRowBound" />

    I would greatly appreciate any insight you could provide regarding the same

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Apr 2014 in reply to Chandan Dey Link to this post


    Please check below link.


    As per your code:
    By default your page size is 10, so Radgrid creates only 11 Radtextbox for tempate column.
    Either you have to set pagesize to 100, so it will creates 101 RadTextbox for tempate column. Then you have set page size 10.

    As per my suggestion please create template column control dynamcally by using javascript. (As per above link).

    Jayesh Goyani
  3. DevCraft R3 2016 release webinar banner
Back to Top