Trim extra spaces from DetailsView data

protected void DetailsView1_DataBound(object sender, System.EventArgs e)
{
 if (sender.CurrentMode == DetailsViewMode.Edit) {
  foreach (DetailsViewRow TrimDetailsViewRow in sender.Rows) {
   foreach (DataControlFieldCell TrimDataControlFieldCell in TrimDetailsViewRow.Cells) {
    if (TrimDataControlFieldCell.HasControls == true) {
     foreach (Control TrimControl in TrimDataControlFieldCell.Controls) {
      if (TrimControl is TextBox) {
       TextBox TrimTextBox = TrimControl;
       TrimTextBox.Text = Strings.Trim(TrimTextBox.Text);
      }
     }
    }
   }
  }
 }
}

No comments:

Post a Comment