I was wondering is someone could give me hand converting this GridView code to work with the RadGrid control.
<%@ 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
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Get Values"
OnClick
=
"Button1_Click"
/>
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
>
</
asp:GridView
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
_Default : System.Web.UI.Page
{
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
TemplateField templateField =
new
TemplateField();
GridView1.Columns.Add(templateField);
templateField.ItemTemplate =
new
MyCheckBoxTemplate();
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
GridView1.DataSource =
new
string
[] {
"a"
,
"b"
,
"c"
};
GridView1.DataBind();
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
foreach
(GridViewRow row
in
GridView1.Rows)
{
bool
isChecked = ((CheckBox)row.FindControl(
"CheckBox1"
)).Checked;
Response.Write(
"RowIndex "
+ row.RowIndex +
": "
+ isChecked +
"<br />"
);
}
}
}
public
class
MyCheckBoxTemplate : ITemplate
{
void
ITemplate.InstantiateIn(Control parent)
{
CheckBox cb =
new
CheckBox();
cb.ID =
"CheckBox1"
;
parent.Controls.Add(cb);
}
}