How do I trim my values in a gridview edit form before they are updated or inserted into the database? I want to be sure that users do not add extra spaces onto the end of the text or at the begining.
SBA-CDeCinko 0 Light Poster
Recommended Answers
Jump to PostYou can do the trimming inside CellEndEdit event.
Jump to PostSorry, I thought you were using DataGridView.
someString.Trim();
returns a string but it doesn't change that string from which it is called.Replace your code with this:
((TextBox)mainGridView.FooterRow.FindControl("insertFirstName")).Text = ((TextBox)mainGridView.FooterRow.FindControl("insertFirstName")).Text.Trim();
Thanks
All 7 Replies
nick.crane 342 Veteran Poster
SBA-CDeCinko 0 Light Poster
farooqaaa 48 Enthusiast
SBA-CDeCinko 0 Light Poster
SBA-CDeCinko 0 Light Poster
farooqaaa 48 Enthusiast
SBA-CDeCinko 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.