日期:2014-05-18  浏览次数:20441 次

怎么取得EditItemTemplate里的TextBox里的改变后的值?
<asp:TemplateField HeaderText="日期"> 
  <EditItemTemplate> 
  <asp:TextBox ID="textOne" runat="server" Text='<%# Bind("rq") %>' ReadOnly="True" ></asp:TextBox> 
  </EditItemTemplate> 
  <ItemTemplate> 
  <asp:Label ID="lblOne" runat="server" Text='<%# Bind("rq", "{0:yyyy年M月d日}") %>'>
  </asp:Label> 
  </ItemTemplate> 
</asp:TemplateField>



怎么取得EditItemTemplate里的TextBox的改变后的值?

TextBox 调用了一个时间控件,为了格式正确性不允许用户手动输入,但是设置成只读后取不到改变后的值

怎么取到?

------解决方案--------------------
添加参数了。 
sqlcmd.Parameters.Add(new SqlParameter("@ProSn", SqlDbType.Int, 4));
sqlcmd.Parameters["@ProSn"].Value = ProGridView.Rows[e.RowIndex].Cells[0].Text;
照这改改
------解决方案--------------------
string time= ((TextBox)GridView1.Rows[e.RowIndex].FindControl("textOne")).Text;
------解决方案--------------------
探讨
string time= ((TextBox)GridView1.Rows[e.RowIndex].FindControl("textOne")).Text;

------解决方案--------------------
C# code
protected void gvTest_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string id = this.gvTest.DataKeys[e.RowIndex].Value.ToString();
        string aa= ((TextBox)gvTest.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString();      
        DbUtil.ExecuteNonQuery("update guestcenter set neirong='"+aa+"'where id=" + id + "");
        this.gvTest.EditIndex = -1;
        this.lianxibind();
    }

------解决方案--------------------
在后台设置只读,TextBox.attributes.add("readonly","readonly")
前台不要加readonly