Web Forms :: How To Change Code To Multiple Selections
Jul 31, 2010string lvStatus =
string.Empty;
if (ClbLeaveStatus.SelectedIndex == 0) [code]..
how to change this code to multiple selections
string lvStatus =
string.Empty;
if (ClbLeaveStatus.SelectedIndex == 0) [code]..
how to change this code to multiple selections
I have a list box that allows for multiple selections (holding down the control key) the selection quantity is basically unlimited, but realistically should never be more than 50 to 100 items from the listing of about 3000 items.
I need to collect the list of selected items from the drop down list and retrieve each of their full records from the item master and populate a gridview.
I have a list box that allows for multiple selections (holding down the control key) the selection quantity is basically unlimited, but realistically should never be more than 50 to 100 items from the listing of about 3000 items.
I could really use some building the SQL statement to select the choosen record data. I think I have the selection list worked out by populating an array but I am not clear on how to build the SQL query.
how to do multiple selection in dropdownlist in asp.net
View 1 RepliesI am trying to populate the value(s) of a listbox that has multiple selections:
Assignment Preference:<br />
<asp:ListBox ID="assignmentPreferenceList" SelectionMode="Multiple" runat="server">
<asp:ListItem Value="">None</asp:ListItem>
<asp:ListItem Value="CONTRACTING">CONTRACTING</asp:ListItem>
<asp:ListItem Value="DIRECT HIRE">DIRECT HIRE</asp:ListItem>
<asp:ListItem Value="CONTRACTING-DIRECT HIRE">CONTRACTING-DIRECT HIRE</asp:ListItem>
</asp:ListBox>
I am using a datareader in code behind to "loop" through the values:
string sql4 = "Select * from assignmentPref where tID=" + (dr["id"].ToString());
SqlCommand comm4 = new SqlCommand(sql4, con3);
SqlDataReader dr4 = comm4.ExecuteReader();
while (dr4.Read())
{
assignmentPreferenceList.SelectedValue = (dr["assignmentPref"].ToString());
}
Works great with 1 assignment preference but with 2 or 3 it craps out.
I have a web form that when completed sends an e-mail with the data from the form. I have a list box that permits muptiple selections and it post to the email with the following code.
sb.Append("<br />Products of Interest:....");
for(int i = 0; i < ListBox2.Items.Count;i++)
{
if(ListBox2.Items[i].Selected)
sb.Append(ListBox2.Items[i].Text);
}
It works fine except that when multiple tiems are selected, they run together on the form. Instead of "Beds Dressers Tables", I get "BedsDressersTables".
How to display checkboxes in dropdownlist ?
Actually I want to select any checkbox(For selecting months) which is listed in dropdownlist?
Using SQL Server 2008, C#, .Net 3.5
I have two tables - Reports, Usage
Report table:
RId
RName
RGroup
Usage table:
UId
UUser
What I want to do is make a page that will list all the reports in the Reports table and have a checkbox next to each name. A user can check each report they use and when they click "submit" it will insert each ReportID into the Usage table.I'm guessing that I should use a GridView to display all the Reports?How would I make it so that the "submit" button would insert each "checked" record into the Usage table?
I'm storing details about clothing in a database, and I need to save multiple entries for colour. For example, a user selects a top, and then needs to select the colours red, black, white and blue from say a group of tick boxes. How should I store this infomation, and what web controls would I use to help the user make there selection?
View 10 Repliesthe form has 15 items to choose with radio buttons, any number can be selected. I would like to process them as a 'group' so I can do something like loop thru them, checking if each one has been selected to build a list and also be saving them to a table row, etc but it seems all the designations as a list or group make it mutually exclusive. just looking for better coding than checking them with an if statement or similar so the question is if there is some way to designate the radio buttons as a group but no force the group to be mutually exclusive
View 4 RepliesThis seems like it should be prettty easy - but I just can't get it to work!I have an enum in my model, which I want to display as a list of checkboxes. The user can select multiple checkboxes, and I want to save this in the database.
So the enum is like so (approx 20 elements unabridged):
public enum ReferrerType
{
[Description("No Data")]
NoData = 9999,[code]....
And it doesn't work! I guess I'm missing something obvious, but I can't work out what. There are no errors - just an empty database table where referrers should be.
How do I handle selection of multiple items with autocomplete? The objects I return from my JSON web service contain an ID and a Label - the ID is the ID of the entity in the database, and the Label is some text to display for the user.
At the moment, when I select an item in the autocomplete dropdown, the value of the item's ID is stored in a hidden field, and the label is displayed. When I remove the label, I clear the ID of the hidden field - this is done by adding an anchor element to the DOM that handles this.
Now, I want to have multiple selections. I want to be able to enter some text, get an autocomplete dropdown, select an item and some other options, then be able to click an 'Add New' button or the likes to be able to select another instance.
For example, I'd type in a person's name and get an autocomplete selection. I'd select a person, and then enter their age, and click 'Add'. The person's id, name, and age will be stored somewhere so that I can retrieve it on the server side when I post back.
I'm not quite sure how to do it? I'm thinking of a hidden field - I assume that many hidden fields of the same name/id turn up on the server side as an array, which I can then use. But I haven't tried this yet in ASP.NET.
I have a requirement to allow users select multiple "Agencies" and populate the "Types" based on that selection. Cascading Drop down would have been a great fit if there is no mutliple selection involved. I am wondering if I could use a popup dropdown with chekcboxes. However, these checkboxes need to be populated dynamically by a web service. I am not very familiar with AJAX toolkit and what control would work best in this case.
View 1 RepliesDoes anyone know if it is possible to have Cascading DropDown Lists which are based on the selected value of more than a single list. Example - I have four tables in a database as follows:
Product
PartA
PartB
PartC
The items in Product are made up by one record from each of the other three tables (PartA + PartB + PartC = Product). What I wish to do is have 3 Cascading DropDown lists which refer to the three individual parts which can be used to select items fromt he Product table.
The first two work no problem but when it comes to the third the list is condition on only items which have the selects of both the first two lists.
I have the followingh scenario where I have a radgrid and inside it, I have a template column containing a check box:
[code]....
However, I only really want the user to be able to select one checkbox at a time.
Therefore, how to I go about ensuring that the any previous 'checks' are removed or stopping multiple checking altogether?
New at SQL and ASP.NET C#, bear with me. I have a form to insert into mulitple tables of a sql db. The form includes two listbox's, categoryIDlistbox and subcategoryIDlistbox, both with the ability to select multiple choices. Idea is that there is one record for the user created (Table1) and then that user can have multiple categories and subcategories assign to him/her in Table2
Table1:
userID
fname
lname
etc...
Table2
userID
categoryID
subcategoryID
If I understand correctly I need to use an array to take the multiple listbox items and save them to the tables. Not sure where the array goes in my code behind page to process the listbox and loop for muliplte selections. Here's my current code behind, where do I place the listbox array?
[Code]....
My question is I have multiple Checkbox Lists and i want to compare it and Filter Datalist records on Checkbox list checked event.. (I want filtering something like [URL]
using System;
using System.Collections.Generic;
using System.Linq;
[Code].....
My problem is If first checkbox list is checked and user clicks on second checkbox list then i want to compare both checkboxes and populate result based on both checkboxes.
I am using this code to generate the current date to label.
Label14.Text = DateTime.Now.ToString
It output as 5/27/2010 10:31:53 AM
However I want only 5/27/2010
How should I change this code ?
I have seen the MVC source code,and I found that the source register the Areas like this:
foreach (Type areaRegistrationType in areaRegistrationTypes)
{
AreaRegistration registration = (AreaRegistration)Activator.CreateInstance(areaRegistrationType);
registration.CreateContextAndRegister(routes, state);
}
so... how can I change the order without change the source code?
Is there an easy way to clear all the selected items of a checkbox list control? When a user has selected multiple items?
View 2 RepliesI have a wizard control handling multiple radiobuttonlists. This is done so a customer can make a selection on one radiobuttonlist then move onto the next one. Each radiobuttonlist pulls selections from table in a database. Each time a customer visits the page, I want them to make selections on each radiobuttonlist then have those selections show up on a summary page when the customer presses checkout. From there, the customer can enter their information which will be stored along with their selections in a separate order table.
So far I have the wizard control set up with each of the radiobuttonlists getting pulled from the database. how I can have these selections show up on a summary page then get stored with the customer information in another database.
handle site navigation and retaining user selections.
On Page 1:
I am using an <asp:ListBox as a filter for an <asp:GridView (gv.datasource=myobj.getdata(lb.selectedvalue))
This functions as expected and the gridview pagination functions as expected.
Each row on the grid provides an <asp:HyperLinkField to navigate to another page (Page 2).
This functions as expected.
On Page 2:
This provides functionality to perform some data creation/manipulation tasks.
It also provides a link to navigate to another page where other tasks can be performed (Page 3).
My query is in relation to returning from Page 3 to Page 2 to Page 1.
I would like to be able to return from Page 3 to Page2 to Page 1 and display earlier selections.
Currently, I am using a combination of querystring parameters and sessions vars on each Page_Load to achieve this.
Q1: What are the recommended ways to achieve this?
Q2: Is it possible to dynamically specify url parameters on a sitemap?
I'm struggling once again to get something centered on a page, and fighting with recalcitrant browsers. I can fix the problem for one browser by adding a style. I can fix it for the other browser by NOT adding the style. I can determine which browser I'm using. If I can change the properties of a div in the code behind, I can create a class and apply it to the div as needed. I added an id to the class:
<div id="alignLV2" runat="server">
but in the code behind, alignLV2 doesn't seem to have a class property. Is there a way to add a class or change the style?
I m trying to change the img src using the code behind.
A dinamic image that the final user can alter anytime and after this he can send that html content to some email adress.
My trouble is that when I change the image using the code behind the img src doesn't come with html content.
I have a page that the user can make selection using a checkbox.. at the end of the page, they have the option email those selections to others. So i'd like to loop thru the gridview if they click on the email button, first make sure they made a selection, if no selection then i will prompt them.. if they select 3 records then i need to put those 3 records into the body of the email.. Ive looked around and found some others with the same end result, but none that provided a good example of building that list dynamically for the email body. im using "using System.Net.Mail;" and have the email working fine with hard coded data for the body, i need to connect to the gridview and build the body.. Can anyone offer suggestions, examples or links to a good tutorial?
View 3 Replies