У меня есть Gridview, которая подается данные из локального БД. Gridview была настроена так, чтобы вы могли редактировать эти данные, которые находятся в строке. Однако, когда вы пытаетесь отредактировать данные, в текст добавлен пробел, добавляемый в текст. Код ниже, любая справка оценена. < /P>
< /code>
c#< /p>
protected void gvActiveStudents_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvActiveStudents.EditIndex = -1;
getStudents();
}
protected void gvActiveStudents_RowEditing(object sender, GridViewEditEventArgs e)
{
gvActiveStudents.EditIndex = e.NewEditIndex;
getStudents();
}
< /code>
Решение: Обрезка пробелов в Rowediting < /p>
string firstname = ((TextBox)gvActiveStudents.Rows[index].Cells[3].Controls[0]).Text.TrimEnd();
((TextBox)gvActiveStudents.Rows[index].Cells[3].Controls[0]).Text = firstname;
string lastname = ((TextBox)gvActiveStudents.Rows[index].Cells[4].Controls[0]).Text.TrimEnd();
((TextBox)gvActiveStudents.Rows[index].Cells[4].Controls[0]).Text = lastname;
Подробнее здесь: https://stackoverflow.com/questions/161 ... nd-of-data