当我在Custom GridView中更新时,TextBox返回null

时间:2019-03-27 11:01:24

标签: asp.net gridview webforms

我正在尝试在GridView中更新数据,当我单击“编辑”时,数据被绑定并显示在TextBox中,但是当我单击“ Update”并对其进行调试时,TextBox返回空值并使用该空值进行更新

protected void grdCustomer_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    TextBox txtUserName = (TextBox)grdCustomer.Rows[e.RowIndex].FindControl("txtUserName");

    command = new SqlCommand("Users_Update", connection);
    command.CommandType = CommandType.StoredProcedure;
    command.Parameters.AddWithValue("Names", txtUserName.Text);
    command.ExecuteNonQuery();

    grdCustomer.EditIndex = -1;
    GetData();
}

0 个答案:

没有答案