Web Forms :: Selecting Multiple Items In Listbox?
Aug 12, 2010
I have a dataTable that contains a specific column from a database. A listbox contains 100 list items in it. When page loads, I need those listbox items to be selected, whose value matches the value in the datacolumn of the datatable.
Following is the code i tried, but is not working. For some reason, it selects only the last item in the datacolumn.
if (datTableRelatedSchool.Rows.Count == 0)
{
}
else
{
foreach (DataRow row in datTableRelatedSchool.Rows)
{
foreach (DataColumn myCol in datTableRelatedSchool.Columns)
{
lstRelatedSchool.SelectedValue = row["RelatedSchoolPK"].ToString();
}
}
}
View 4 Replies
Similar Messages:
Feb 18, 2010
I've a list box which may contain 300000 or more records. I've another listbox . The user basically selects from the first listbox and adds to second lbx. There is button which when clicked will move the selected records from first listbox to second listbox.
Now if I select around 45000 records and try to move to second listbox .. it moves fine . If I select more than 45000 or so...it takes very long and eventually i get the "Action Cancelled". When I put a break point in page_init ..it does not hit. Is there a way I can restrict the user by selecting more than 40000 items. ie they should not be able to highlight more than 45000 records.
View 1 Replies
Feb 16, 2010
I'm using a listbox to save multiple selected value in db. I'm saving that values by seperating comma(,). In edit option i want to reterive the same value from db and want show multiple selected items in listbox.
View 9 Replies
Jun 18, 2010
I had used listbox control with multiple selection mode. I stored id with comma delimiter in database.
e.g.
1. List Item One.
2. List Item Two.
3. List Item Three.
4. List Item Four.
5. List Item Five.
6. List Item Six.
Suppose user select item 2, 4 & 6. So I will store it as a 2,4,6 in database. This will work fine.
Now in editing I have to shows selection-bar for item 2, item 4 & item 6. So I had typed below source.
string strData ="2,4,6"
if(strData != null)
{
char[] separator = new char[] { ',' };
string[] strSplitArr = strData.Split(separator);
int x = 0;
for (x = 0; x < strSplitArr.Length; x++)
{
// lstWDef_PurchasesEdit.Items[x].Selected = true;
lstWDef_PurchasesEdit.SelectedValue = strSplitArr[x].ToString();
}
}
But with this statement I got only last item id as a selected item with selectionbar. In our example 2,4,6 only item whoseid is 5 got as a selected item.
if i use
for (x = 0; x < strSplitArr.Length; x++)
{
if (lstWDef_PurchasesEdit.Items[x].Value == strSplitArr[x])
{
lstWDef_PurchasesEdit.Items[x].Selected = true;
}
}
if the selected items are serial like 2,3,4 then it is displaying correctly..
if items are 2,4,6 then it is not selecting the items of listbox properly.
Is anybody guide me how to make item 2, item 4, item 5 as a selected item ?
View 4 Replies
May 8, 2010
I have two ListBoxes. I can move items from one list box to the other. I have an Insertcommand for inserting added values from the "ActivePrograms" list box to a db.
my problem is that it inserts only one item when sometimes the user added multiple items.
how do I insert all existing items from "ActivePrograms" list box?:
second issue: how do I make sure the insert command go through the list of items in the listbox and makes sure these rows does mot already exsited in the db? in other words insert only NEW values for that 'Id' value
[Code]....
View 8 Replies
Aug 14, 2010
I want to select the multiple items in the listbox.....for eg in my listbox there are five items
apple,pear,lotus,red,blue.on button click i want to select two items from the listbox.
How to do....
View 6 Replies
Aug 5, 2013
I would like to fill the textbox autocomplete stringcollection "on the fly" while typing. using with the Particular symbols Like @,#
Same as twitter "Compose new tweet" textbox
And the Data from the backend...
View 1 Replies
Dec 9, 2010
I have two databound listboxes. The first only shows items that have been assigned to my product. The second listbox shows all available items. What I want to do is select all of the items in listbox 2 that list box one contains.
For example:
ListBox1-
Item 1
Item 3
ListBox2-
Item 1 (Selected)
Item 2
Item 3 (Selected)
Code I have:
List<string> myList = new List<string>();
foreach(ListItem f in ListBoxSourceDetail.Items)
{
myList.Add(f.Value);
}
myList.ForEach(delegate(string n)
{
ListBoxSourceEdit.SelectedValue = n;
});
View 1 Replies
Jul 29, 2010
I am persisting the search selection criteria of a listbox onto another page which is called AreasLb. Multiple areas can be selected, I simply want to set the listbox items that the user selected as .Selected = true
I think the below code should work, but it doesn't, with no items in the Listbox being selected.
if (s == "Areas")
{
string[] area = nv[s].Substring(0, (nv[s].Length - 1)).Split(';');
int i = 0;
foreach (ListItem item in AreasLb.Items)
{
foreach (var s1 in area)
{
if (s1 == item.Value)
{
AreasLb.Items[i].Selected = true;
}
continue;
}
i = i + 1;
}
continue;
}
View 2 Replies
Nov 10, 2010
I'm trying to use the ListBox html helper in a simple form.
verhuurPrijzenLst is a simple list that gets put into the ListBox, I think I need "MultiSelectList", but I cannot use it (MVC framework needed)?
I don't know exactly how to do that ( bin folder and @inherits ? )
So it's nice to have a helper at hand, but if you cannot use it properly without using the MVC framework, that is a pity.
[Code]....
View 4 Replies
Jan 4, 2011
How can I update the database with more than one item selected from the List Box. What I am currently doing updates only one item
objprp1.plugin_id = Convert.ToInt32(ListBox1.SelectedItem.Value);//passing the value(id) of the plugin thru the listbox property
View 5 Replies
Mar 23, 2010
I have a listBox that is bounds its content from the database. This control is inside an itemTemplate. When the item template is boudned, I want to select the corresponding value.
I have this ugly single line of code:
[Code]....
What it does is to select the right value to a ListBox that is databinded with values inside a DetailsView
here is the rest of the code:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="SqlDataSource4"
EnableModelValidation="True" ondatabound="DetailsView1_DataBound">
<Fields><asp:TemplateField><ItemTemplate>
<asp:ListBox ID="lbATechAuthCheck" runat="server" Width="100%" DataSourceID="SqlDataSource2" DataTextField="status" DataValueField="id"></asp:ListBox><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString
%>"SelectCommand="SELECT * FROM [Status]"></asp:SqlDataSource>
</ItemTemplate></asp:TemplateField></Fields></asp:DetailsView>
Is there an easier way to achieve the same thing perhaps without any code behind?
View 7 Replies
Apr 10, 2010
I am trying to pre-select checkboxes in a CheckBoxList control. The datasource provides three useful columns per item: id, name, selected_flag.
View 2 Replies
Jul 18, 2010
i have the following problem. i'd like to use a listview with paging for mulitple selection of items in a list. The selection is no problem. I do have f.i. a list which holds the key values.
List<Int64> selectedList =
new
List<Int64>();
As soons as the user makes a selection or removes a selection the list will be updated accordingly. Also hold this list info when changing pages of the listview.
[Code]....
This list can be stored either in a session or a viewstate.
My question is how can i retrieve the information of the list back into my listview and thus displaying the selection the user has made when he jumps from page to page.
Below my listview.
[Code]....
View 2 Replies
May 17, 2010
have trouble with grid view,I want to select specified items and show them in labels or text boxes.I don't want to use check boxes ...E.g:I want to use for or foreach methods and show all the items in column (1) in text boxes respectively.
View 10 Replies
Aug 17, 2010
I have a databound listbox that is inside an update panel. When selecting an item in the listbox, I want it to populate labels in a panel that are displayed in a modalpopup. When I click on the listbox, I can see that the data is passed to the labels and the modal.Show() is executed by stepping through the code. However, the modalpopup comes up but with no data.
[code]....
View 3 Replies
Jan 26, 2010
I am moving an app from Silverlight back to ASP.NET. (Don't ask!) I really liked the ability to highlight ListBox items as the user moved the mouse over the items. I have been Bing'ing all morning and cannot seem to find any way to do this in ASP.NET with an ASP:ListBox. I tried setting the onmouseover event for the list items themselves. But that did nothing.
[Code]....
I then tried setting onmouseover event for the list itself. I can get the event, but I don't know how to determine which item I am over. I only seem to have the selectedIndex. If I am just moving the mouse, I have no selectedIndex.
View 3 Replies
Feb 8, 2010
I am not able to give spaces between two items in list box. I tried with css- padding, but no luck.
View 6 Replies
Jun 29, 2010
How to get all items from Listbox. i need to load all item from Listbox to my database. how to get collection of item and how to save it into databse.
View 3 Replies
Jul 13, 2010
Can you append items to a listbox?
View 13 Replies
Nov 16, 2010
I start building asp.net web site for my office. I have a listbox with province ID and name. How do i select all item on page_load?
View 2 Replies
Nov 16, 2010
When I have multiple entries with the same id in a list box the selected index is always the first instance of the item. How do I get around this without modifying the id of the items in my list box so they are unique?
View 2 Replies
Jan 18, 2011
I'm trying to populate 1000 ListItems in a ListBox.
how to do it. Currently only 100 items are being displayed even though I set the capacity of the ListBox to 1000.
Below is sort of how my code looks like. :)
listBox.Items.Capacity = 1000;
foreach(entity ent in enitityCollection)
{
ListItem listItem = new ListItem();
listItem.Value = ent.Id.ToString();
listItem.Text = ent.Name;
listBox.Items.Add(listItem);
}
entityCollection has 989 records in it.
Code does not generate any error. only that at the end of the loop I only get 100 items mapped to my ListBox.
Is this how the ListBox is designed for?
View 3 Replies
Aug 17, 2010
txtquantity.text = lborderlist.Items.Count.ToString(); -> this codes adds how many you have input in the listbox, now i need to know the opposite..
how to remove items from a listbox but it should also counts the how many you have left in the listbox..
View 7 Replies
Oct 24, 2010
i want to create a dynamic listbox where items are links (each item is a hyperlink)
here 's my code:
Using sw As StreamWriter = New StreamWriter(Server.MapPath("~/Output/" & weeknumber & ".xls"))
Dim hlk As New HyperLink
hlk.NavigateUrl = ("~/Output/" & weeknumber & ".xls")...
View 5 Replies