<%@ 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"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
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"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
//Put your JavaScript code here.
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
div
>
</
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
CellSpacing
=
"0"
Skin
=
"WebBlue"
>
<
ExportSettings
>
<
Pdf
>
<
PageHeader
>
<
LeftCell
Text
=
""
></
LeftCell
>
<
MiddleCell
Text
=
""
></
MiddleCell
>
<
RightCell
Text
=
""
></
RightCell
>
</
PageHeader
>
<
PageFooter
>
<
LeftCell
Text
=
""
></
LeftCell
>
<
MiddleCell
Text
=
""
></
MiddleCell
>
<
RightCell
Text
=
""
></
RightCell
>
</
PageFooter
>
</
Pdf
>
</
ExportSettings
>
<
ClientSettings
AllowKeyboardNavigation
=
"True"
>
<
Selecting
CellSelectionMode
=
"MultiCell"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
ShowFooter
=
"False"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
Created
=
"True"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
<
BatchEditingSettings
EditType
=
"Cell"
></
BatchEditingSettings
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
</
MasterTableView
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
<
SelectedItemStyle
BackColor
=
"#FF9999"
/>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Highlight any cells in the grid above then click this button. Do that twice, and notice how it is off by one column."
onclick
=
"RadButton1_Click"
Height
=
"112px"
Width
=
"1263px"
Font-Size
=
"Large"
>
</
telerik:RadButton
>
<
p
>
</
p
>
</
form
>
</
body
>
</
html
>
//the following is code-behind (default.aspx.cs)
using
System;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Configuration;
using
System.Web.Security;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//populate RadGrid with test table data
if
(IsPostBack ==
false
)
{
RadGrid1.DataSource = GenerateTestTable( );
RadGrid1.DataBind();
}
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
//do something with selected/hilighted cells - WHY IS IT OFF BY ONE COLUMN?!?!?!?!?!?!?
foreach
(GridTableCell item
in
RadGrid1.SelectedCells )
{
item.Text =
"Hello!"
;
item.BackColor = System.Drawing.Color.Aquamarine;
}
}
static
DataTable GenerateTestTable()
{
// create DataTable columns
DataTable dt =
new
DataTable();
for
(
int
i = 0; i < 8; i++) { dt.Columns.Add(
"Column_"
+ i.ToString(),
typeof
(
int
)); }
// create DataTable rows
DataRow dr =
null
;
for
(
int
row = 0; row < 8; row++)
{
dr = dt.NewRow();
for
(
int
col = 0; col < 8; col++) { dr[col] = col +row*8; }
dt.Rows.Add(dr);
}
return
dt;
}
}
// why is it off by one column?!?!?!?!?