M3hcSS
asked on
Replace text inside a gridview/detailview with different text.
I have a field inside a gridview/detailsview that pulls data from a database. That field is a bound field.
I want to replace the original text inside that field with text that's been parsed out of the original text.
Example:
My Field
----------
blah blah blah NOVEMBER blah blah
then, replace original text with just NOVEMBER
My Field
---------
NOVEMBER
I do already have a function that can parse out NOVEMBER; I don't know how to tell my gridview/detailsview to run that function.
I want to replace the original text inside that field with text that's been parsed out of the original text.
Example:
My Field
----------
blah blah blah NOVEMBER blah blah
then, replace original text with just NOVEMBER
My Field
---------
NOVEMBER
I do already have a function that can parse out NOVEMBER; I don't know how to tell my gridview/detailsview to run that function.
public string ParseForField(string TextString, string TargetField)
{
string[] Fields = TextString.Split(';');
foreach(string Field in Fields)
{
if (Field.Contains(TargetField))
{
return Field.Trim();
}
}
return "No field by that name.";
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.