在GridView的DataBound事件中 TEXT 绑个委托事件
//我想在 退费数量中输入数量里金额 也一样变,可 执行不到tfsl_TextChanged 中 为什么?
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GridView1.DataBind();
}
}
protected void tfsl_TextChanged(object sender, EventArgs e)
{
//do something
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox tbx = (TextBox)e.Row.FindControl("tfsl");
tbx.TextChanged += new EventHandler(tfsl_TextChanged); ;
}
}
}
<asp:TemplateField HeaderText="退费数量">
<ItemTemplate>
<asp:TextBox ID="tfsl" runat="server" Width="45px" OnTextChanged="tfsl_TextChanged"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
------解决方案--------------------这个js代码不复杂,楼主试着敲出来吧
------解决方案--------------------前台
tfsl_TextChanged()
{
//do something
}
<asp:TextBox ID="tfsl" runat="server" Width="45px" OnTextChanged="tfsl_TextChanged()"> </asp:TextBox>