I have a SPGridView that displays items from a list (using spboundfield).
The multi-lookup fileds in my SPGridview the filter values of a lookupfield appear in this format:
{id};#{Value}
How do I replace the id;# from the field?
Here is how I solved this issue. (NOTE i had to put a dot before asp and itemtemplate for this post. remove those dots)
asp:TemplateField HeaderText="Campaign Members">
ItemTemplate>
%# RemoveCharacters(Eval("CampaignMembers").ToString())%>
/ItemTemplate>
/asp:TemplateField>
// Make sure declare using System.Text.RegularExpression;
protected string RemoveCharacters(object String)
{
string s1 = String.ToString();
string newString = Regex.Replace(s1, #"#[\d-];", string.Empty);
newString = Regex.Replace(newString, "#", " ");
return newString.ToString();
}
Related
I have created an xPages custom control based on Dynamic View Panel. I then added 2 comboboxes filled with various values (States, Departments) and an editbox field and a Search button. I then coded the follow to return the search string onto a computed "Search in view results" for the panel.
var tmpArray = new Array("");
var cTerms = 0;
if(viewScope.categoryText1 != null) {
if ( viewScope.categoryText1.trim() != "") {
tmpArray[cTerms++] = "(FIELD State CONTAINS \"" + viewScope.categoryText1 + "\")";
}
}
if(viewScope.categoryText2 != null ){
if ( viewScope.categoryText2.trim() != "") {
tmpArray[cTerms++] = "(FIELD Department = \"" + viewScope.categoryText2 + "\")";
}
}
if(viewScope.searchString != null ) {
if ( viewScope.searchString != "") {
tmpArray[cTerms++] = "( \"" + viewScope.searchString + "\")";
}
}
qstring = tmpArray.join(" AND ").trim();
viewScope.queryString = qstring; // this just displays the query
return qstring // this is what sets the search property
The search works for the editbox field values but not for the strings generated by the comboboxes: 'FIELD State CONTAINS "some state"' or 'FIELD Department = "some deptname"'. These search strings return an empty view.
The Column names match the underlying Notesview (both programmatically and column title).
I think this might have something to do with what are the column names surfaced by the Dynamic View Panel but I'm not sure.
Full text search looks in document fields for search strings, not in column values.
So, make sure fields State and Department contain the strings you are looking for.
Do you use aliases? Maybe you save abbreviation for State in document only but user can select State's full name for search...
I am doing a Vaadin project and maybe it's easy question but my brain is stop working right now.
I have a Table which code is like:
Table table = new Table();
table.addContainerProperty("Value", String.class, "");
table.addContainerProperty("combo", ComboBox.class, null);
table.addItem(new Object[]{"asd123", combo1}, 1);
table.addItem(new Object[]{"asd1234", combo2}, 2);
combo1 and combo2 are ComboBoxes, their code is like:
ComboBox combo1 = new ComboBox();
combo1.addItem("Choice 1");
combo1.addItem("Choice 2");
ComboBox combo2 = new ComboBox();
combo2.addItem("Girls");
combo2.addItem("Boys");
I want to access an item on table, and hold this as String.
Assume that there is a String str and String str2 variables, and I want that (str = asd123) and (str2 = combo2's selected element).
How can I do that?
If you can help, I appreciate that.
table.getItem(itemId);
// or
combo2.getValue();
However, these functions both return Object values so you have to typecast them to String before using them properly.
String str = (String) table.getItem(itemId);
For further reference see Vaadin Table and Vaadin ComboBox.
Hi i want to set a text to three textblocks from service url
"http://www.findyourfate.com/rss/yearly-horoscope.asp?sign=Aries",which is a single string,
I just want to split three strings and setting the text to three textblocks of
text1,text2,text3.idone setting why i'm splitting means in single textblock not displaying full content because of this reason i thought to split into three strings.for first text block what i neede to display has been done sucessfulyy ,I tried to set for rest of the textblock but i'm stuck please help me to resolve this issue.I'm begginer to this windows 8 development please help me.
try
{
XDocument xmlDoc = XDocument.Parse(e.Result);
var result = xmlDoc.Descendants("channel");
List<xmlList> _xmList = new List<xmlList>();
foreach (var item in result)
{
var node = item.Descendants("item");
//XDocument xdoc = XDocument.Load(e.Result);
foreach (var xElememt in node)
{
string description = xElememt.Element("description").Value;
MessageBox.Show("" + description.Length);
string input = description;
int pattern = input.IndexOf("CAREER");
int pattern1 = input.IndexOf("RELATIONSHIP");
int pattern2 = input.IndexOf("FINANCE");
string str1 = input.Substring(0,pattern);
string str2 = input.Substring(pattern,pattern1);
string str3 = input.Substring(pattern2);
text1.Text = str1;
text2.Text = str2;
text3.Text = str3;
}
You could use the String.Split Method in order to split a string.
Reference: C# Split A String By Another String
You don't have need to split the string and also no need to use three textblocks,
You can use RichTextBox control to show the information.
It will show your full content of description
use the bellow code with scrollbar in .xaml page
<ScrollViewer
VerticalScrollBarVisibility="Visible"
ManipulationMode="Control"
Height="400"
Margin="0,0,0,-13" >
<RichTextBox TextAlignment="Justify"
IsReadOnly="True"
Margin="0,0,0,10">
<Paragraph Foreground="#626262"
FontSize="17"
FontStyle="Normal"
FontFamily="Regular" >
<Run x:Name="txtDescription" />
</Paragraph>
</RichTextBox>
</ScrollViewer>
and set the value of description to txtDescription in .xaml.cs file
txtDescription.Text = xElememt.Element("description").Value;
I have two strings stored with CoreData and I would like to display them both in a tableview cell.
I tried:
cell.textLabel.text = data.valueForKey("firstName, lastName") as? String
with "firstName" being one key and "lastName" being the other, but this won't compile. When I enter multiples like this:
cell.textLabel.text = data.valueForKey("firstName") as? String
cell.textLabel.text = data.valueForKey("lastName") as? String
it only displays the last value (in this case "lastName") in the tableview cell.
Can anyone tell me how to display both the "firstName" and "lastName" on a tableview cell simultaneously?
cell.textLabel.text = data.valueForKey("firstName") as? String
cell.textLabel.text = data.valueForKey("lastName") as? String
Your second assignment is overwriting the first. You need to concatenate the strings together, presumably with a space or a comma between them.
let firstname = data.valueForKey("firstName") as? String
let lastname = data.valueForKey("lastName") as? String
let separator = ", "
let label = lastname + separator + firstname
cell.textLabel.text = label
I am trying to delete selected text from textbox and enter new character in place of it.
For example, if textbox consists of 123456 and I select 345, and press r on the keyboard, it should replace the selected text.
here is my code:
string _selectText = txtCal.SelectedText;
string _text = Convert.ToString(btn.Text);
if (_selectText.Length > 0) {
int SelectionLenght = txtCal.SelectionLength;
string SelectText = txtCal.Text.Substring(txtCal.SelectionStart, SelectionLenght);
txtCal.Text = ReplaceMethod(SelectText, _text);
}
//replace method function
public string ReplaceMethod(string replaceString, string replaceText) {
string newText = txtCal.Text.Replace(replaceString, replaceText);
return newText;
}
Can anyone show me where my mistake is?
The replace-based answer offered above may well replace the wrong instance of the selection, as noted in the comments. The following works off positions instead, and doesn't suffer that problem:
textbox1.Text = textbox1.Text.Substring(0, textbox1.SelectionStart) + textbox1.Text.Substring(textbox1.SelectionStart + textbox1.SelectionLength, textbox1.Text.Length - (textbox1.SelectionStart + textbox1.SelectedText.Length));
The following does what you want and then selects the replacing text :)
string _text = Convert.ToString(btn.Text);
int iSelectionStart = txtCal.SelectionStart;
string sBefore = txtCal.Text.Substring(0, iSelectionStart);
string sAfter = txtCal.Text.Substring(iSelectionStart + txtCal.SelectionLength);
txtCal.Text = sBefore + _text + sAfter;
txtCal.SelectionStart = iSelectionStart;
txtCal.SelectionLength = _text.Length;
Try this instead
if (textbox1.SelectedText.Length > 0)
{
textbox1.Text = textbox1.Text.Replace(text1.Text.Substring(textbox1.SelectionStart, textbox1.SelectionLength), btn.Text);
}
This is essentially the same as other answers, but formatted differently using C# 6.0.
// If there is selected text, it will be removed before inserting new text.
// If there is no selected text, the new text is inserted at the caret index.
string before = textBox.Text.Substring(0, textBox.SelectionStart);
string after = textBox.Text.Substring(textBox.SelectionStart + textBox.SelectedText.Length);
textBox.Text = $"{before}{insertText}{after}";
textBox.CaretIndex = $"{before}{insertText}".Length;
Note that I set the CaretIndex to a new position after changing the text. This may be useful since the caret index resets to zero when changing the text like this. You may also want to focus the textbox to draw the user's attention to the change and allow them to know where the caret currently is.