TemplateDataField

时间:2021-09-01 18:44:20

.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();

相关文章