.aspx

<ig:TemplateDataField Key="TemplateField_0">
<Header Text="selected">
</Header>
<ItemTemplate>
<asp:TextBox ID="t1" Width="95px" runat="server"></asp:TextBox>
</ItemTemplate>
</ig:TemplateDataField>

校验

for (int i = 0; i < grdMain.Rows.Count; i++)
{
Control c;
c = new TextBox();
(c as TextBox).Width = new Unit(80, UnitType.Percentage);
(c as TextBox).Attributes.Add("onKeyPress", @"if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;");
(c as TextBox).Attributes.Add("onafterpaste", @"this.value=this.value.replace(/[^\d.]/g,'')");
(c as TextBox).Attributes.Add("onkeyup", @"this.value=this.value.replace(/[^\d.]/g,'')");
c.ID = "mycontrolid";
(gridMain.Rows[i].Items[0].FindControl("t1") as TextBox).Controls.Add(c);
}

获得值
Control c = gridMain.Rows[i].Items[0].FindControl("t1");
if (c != null)
{
return (c as TextBox).Text;
}
return "";

string input = ((TextBox)(this.gridMain.Behaviors.Selection.SelectedRows[i].Items[0].FindControl("t1"))).Text.Trim();

05-11 20:37