日期:2014-05-17 浏览次数:20419 次
public void tableBind() { //动态添加数据(只取了一小部分代码) for (i = 0; i < ds.Tables[0].Rows.Count;i++ ) { txtbox.ID = "tb" + i.ToString(); txtbox.Attributes.Add("OnBlur", "javascript:ChangeText();");//加一个焦点获得事件 } }// public int imarkbind() { int imark = 0; foreach (System.Web.UI.Control con in this.Page.FindControl("divform").Controls) { if (con is System.Web.UI.WebControls.TextBox) { if ((((TextBox)con).Text.Trim())!="") { imark = imark + Convert.ToInt32(((TextBox)con).Text.Trim());//求和 } } } return imark; }
function ChangeText() { document.getElementById("tbTransportPoint").value = <%=imarkbind() %>;//tbTransportPoint为和显示的textbox }