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

RadGrid doesn't support TemplateColumn while Binding to DataTable

3 Answers 72 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Ray
Top achievements
Rank 1
Ray asked on 06 Jan 2014, 03:38 PM
A page uses a RadGrid :
1. DataBind to a DataTable.(on Page_Load)
2. GridTemplateColumn , put a RadTextBox (in .aspx file)

no compile warning or errors, run in IE, the grid  in displayed very strange.
snapshot pic is here: http://i.imgbox.com/abhkG4MO.png

codes:
1. WebForm1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" CellSpacing="0" Culture="zh-CN" GridLines="None">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn DataField="name" FilterControlAltText="Filter name column" HeaderText="name" UniqueName="name">
                    </telerik:GridBoundColumn>
 
                    <telerik:GridTemplateColumn DataField="age" FilterControlAltText="Filter age column" HeaderText="age" UniqueName="age">
                        <ItemTemplate>
                            <telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Eval("age") %>'></telerik:RadTextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </form>
</body>
</html>


2. WebForm1.aspx.cs
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                DataTable dt = new DataTable();
 
                dt.Columns.Add("name");
                dt.Columns.Add("age");
 
                for (int i = 0; i < 20; i++)
                {
                    DataRow r = dt.NewRow();
 
                    r["name"] = "name" + (char)('A' + i);
                    r["age"] = i;
 
                    dt.Rows.Add(r);
                }
 
                RadGrid1.DataSource = dt;
                RadGrid1.DataBind();
            }
        }
    }
}



3 Answers, 1 is accepted

Sort by
0
Ray
Top achievements
Rank 1
answered on 06 Jan 2014, 03:41 PM
attach a picture that the grid strange displayed
0
Accepted
Venelin
Telerik team
answered on 09 Jan 2014, 10:03 AM
Hello Ray,

Do you use VisualStudio 2013? If so please download the latest internal build where a similar issue was fixed. Please also refer to this forum thread for more information: http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-does-not-render-opening-table-tag-in-visual-studio-2013.aspx

Regards,
Venelin
Telerik
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 the blog feed now.
0
Ray
Top achievements
Rank 1
answered on 10 Jan 2014, 02:40 PM
I'm using VS2013.
Refer to the thread ,my problem got fixed .
(Add the element below to my web.conifg appSettings section:<add key="vs:EnableBrowserLink" value="false" />)
Venelin
,Thank you very much!
Tags
Ajax
Asked by
Ray
Top achievements
Rank 1
Answers by
Ray
Top achievements
Rank 1
Venelin
Telerik team
Share this question
or