var myList = new List<string> { "red", "blue", "green" };
Regex r = new Regex("\b(" + string.Join("|", myList.ToArray()) + ")\b");
MatchCollection m = r.Matches("Alfred has a red and blue tie and blue pants.");
Is there a way to derive a List<string> of the "found" items ("red", "blue", "blue")?
I'm designing my own custom control that contains a .NET dropdownlist. What I'm wondering is if it is possible to populate my dropdownlist with listitems placed in a placeholder? For example:
This doesn't work because the DropDownList control only allows ListItems as child controls. But, I want to do something similar to this so when the user includes my control on a page, they can do something like this:
Is it possible to select values from a List, where the items contain in a different list aswell?for example;
[Code]....
What I need are all the items from the first list "Items", where the string contains something from the second list "List".So I need something which returns the first 3 items (which contain the term "Item") from the first list.
I added a dropdown lis to my from and when I run the page it says The name ddlTyp[e doesnot exist in current context. Intellisense can find it. but still I am getting this error.
I'm having a little trouble with using regex in linq. I want to be able to perform a search on values in my database. The goal is to insert a value into the regex and then use that to search a column in a table in my database for that term. I want it to work so that it gets all exact matches and also returns matches in which the search term is a substring of the term in the column.
I was trying to follow this tutorial on msdn, but it doesn't quite fit perfectly with my problem:
I have a gridview in which dtasource binded is a List which returns class type. If no records in list, I want to display 'No records found' in GridView.
[code]...
In else part, what code i have to write to get desired output?
I am trying to get a simple multi-page program to run correctly. I have everything set up, except for the "remove" function. When I try to remove an item from the list box nothing happens. Insted of trying to explain it I will show you the code...
ave a webpage that maintains a list of items. Each item is displayed as a simple short text string and has a int/string data value associated with it. At the moment I am displaying the list as a common separated string. I can generate the present string very simply from the result of a linq query:
string displayString=""; foreach (var i in linqResult) displayString = displayString + ", " + i.Name; displayString = displayString.SubString(2);
However, I want to modify the page so that the user can remove any item (name) from the displayed list
I am trying to add the value from a textbox which is also in the formview into the dropdownlist as a list item. I currently have this code for it: Protected Sub Formview1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.PreRender Dim dropdown As DropDownList Dim listvalue As TextBox dropdown = FormView1.FindControl("dropdownlist5") listvalue = FormView1.FindControl("textbox1") dropdown.Items.Add(New ListItem(listvalue.Text, listvalue.Text)) End Sub
This code works and adds the new item to the dropdownlist if I have no SelectedValue set for my dropdownlist. However when I set the selectedValue I get the error message:
"'DropDownList5' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
This is the bit I dont understand because the value does now exist in the list of items as it was added in from the textbox value. Does it try to do the selectedValue before adding my list item? If so how can I add the list item first, or do I need to set the selectedValue in the code after adding the list item?
Another niggling issule. I am trying to remove all the databound items from my listview but it doesn't work. I am trying to remove the items as i have used the delete command button (alongside with the updateand edit)
I have an object, that has many properties but the only two to worry about are:
myobject.ID which is an int myobject.Names which is a HashSet
Then I have a List of those objects that looks something similar to this:
List<myobject>
I use Linq to get a some of the data into a repeater, but I'm not sure how to get the list of Names and how often they show up.
Want to use Linq to avoid having to loop through the data.
As my tags should show, this is an ASP.NET solution using C#.
Some clarification: Lets say I have just three items in my list: Item 1 has John, Fred, Jack in its names. Item 2 has John, Fred, Joe in its names. Item 3 has John in its names.
I am trying to return the following: John - 3 Fred - 2 Jack - 1 Joe - 1
Also, as a note I am familiar with having to write my own comparer for my object, I'm just missing the 'how to' for the overall solution in my thoughts.
I have a List in which I select users from db each time a sql query runs with certain value and selects one user in the time thus I cannot limit identical users in sql.
Here is my code which insert listbox items table and create record.
protected void Button1_Click(object sender, EventArgs e) { ListItem li = new ListItem(); System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= C:Ruchitaweb" + @"WebSite527afcergonomic.mdb"; conn.Open(); for (int i = 0; i < ListBox1.Items.Count; i++) { li.Text = ListBox1.Items[i].Text; } OleDbCommand cmd = new OleDbCommand("insert into record(recorditem) values('" + li.Text + "')", conn); cmd.ExecuteNonQuery(); conn.Close(); }
this is inserting in diffrent rows but i want this in one row with (,)so i can parse it and get it back which items user selected. and i also want to show messge box that show the record number.
I have a list of Key/Value pairs. basically its a List where ViewModel is a custom class of the form
public class ViewModel { public String Key { get; set; } public String Value { get; set; } }
In the View i would need to render Label and Textbox for Key and Value respectively.Im trying to use Html.DisplayFor() however it goes with model and only displays the properties of the model and not the list.I would like to achieve something of the format
in one page i have list box on one button click i am showing on popup which is another aspx pagein that page showing one grid with check box now i want that when user select check boxes and click on add button selected items should gets added to list box on page when i click save button on page(not popup) all the records in that list box should gets saved to data base how to do this
Is there a simple way of putting all list items from a listbox into a textfield? I'm not interested in selecting individual items, I want all items in the box to appear. I'd like the items to appear in the textbox as x, y, z, or x y z. The seperator type / format isn't important as long as long as there is some sort of spacing between each item.
I have a list with multiple selection enable, wen i do a loop in back end to see which items are selected it always just shows me the first one as selected only and everything else false.