更新gridview控件时如何剥离空格 [英] How strip white spaces when updating a gridview control
本文介绍了更新gridview控件时如何剥离空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新gridview文本框以删除空格
我尝试过:
I am trying to update a gridview textbox to remove white spaces
What I have tried:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && GridView1.EditIndex != e.Row.RowIndex)
{
TextBox Tstr = (TextBox)e.Row.FindControl("TextBox1");
if ( !string.IsNullOrEmpty(Tstr.Text))
{
string str = Tstr.Text;
str = str.Replace(" ", String.Empty);
Tstr.Text = str;
}
}
}
推荐答案
这是一个关于如何用单个空格替换空格的示例,当然您可以修改它以返回空字符串。
CP_Replace具有单个空格的空格 [ ^ ]
这是一篇关于Codeproject如何从字符串中删除空格的文章。
最快的方法从.NET中的字符串中删除所有空格 [ ^ ]
Google搜索
asp.net替换空白 [ ^ ]
Here is an example on how to replace whitespaces with single space, of course you can modify it to return empty string.
CP_Replace Whitespaces with single space[^]
Here is an article on Codeproject on how to remove whitespace from a string.
Fastest method to remove all whitespace from Strings in .NET[^]
Google Search
asp.net replace whitespace[^]
这篇关于更新gridview控件时如何剥离空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文