How to remove characters from a string in ASP.net 2.0
5 answers
I think I have an idea what you are talking about, Joy.
You have a GridView that you directly bind using a data source with the AutoGenerateColumns attribute true. To get the title how you want it to appear, you can modify your SQL query like this:
SELECT
ME_NAME AS [Name]
FROM
TABLE
EDIT: And as you said you want to do it from the frontend, you can hook into the GridView's OnRowDataBound event and in that write the following code -
if(e.Row.RowType == DataControlRowType.Header)
{
//Apply the logic for removing the "ME_" string from the header columns.
}
+3
a source to share
If your strings always start with the same value, or with very limited variations, a simple one .Replace()
should do the job:
String str = "ME_NAME";
String str2 = "ANOTHER_NAME";
str = str.Replace("ME_", String.Empty); // str == "NAME"
str2 = str2.Replace("ME_", String.Empty).Replace("ANOTHER_", String.Empty);
If the option is larger, you may need to use Regular Expressions .
0
a source to share