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
2. WebForm1.aspx.cs
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>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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();
}
}
}
}