Editing an asp.net DropdownList - asp.net

I have a dropdown list of 5 elements. My problem is that I want to make this dropdown list editable. Basically a user might want to delete one of these elements or might want to add more elements. Whats a good approach of doing that in asp.net ?

Use a ComboBox.

You have to put textbox for typing text and button for user to insert into the list and button for delete
Do you know the code to adding and deleting list in the dropdown list right ?

Use a ListBox - that way they can make a multi-selection of their choice:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listbox.aspx
The DropDownList is not intended for multi-selection. Another option would be to use CheckBoxes.

If you use DataBase, u can make dropdownlist MORE editable with elements like "formView", "gridView" and so on..

Related

Flex 4: how to have a drop down list of Checkboxes

How would I get a drop downlist to populate with check boxes.
I am porting a c# project to flex, and I would like to imitate the functionality of their checkbox drop list.
Anyone got any idea how I would go about this.
Please and thank you.
Typically you do this by creating a custom ItemRenderer and assigning it to your DropDownList. Here's an example of creating/applying a custom ItemRenderer in a DropDownList:
http://blog.flexexamples.com/2010/05/13/setting-the-text-roll-over-color-on-a-spark-dropdownlist-control-in-flex-4/
Hope that helps.
you could extend the popup-button and add custom item renderer for the items in the dropdown.
http://www.adobe.com/livedocs/flex/2/langref/mx/controls/PopUpButton.html

ListView Edit item Position

I have a Listview in my aspx page with Insert template and Edit template. and a Add New LinkButton.
When a user clicks on Add New LinkButton I am able to specify Insertitem Position so that the Insert TEmplate appears at the bottom of the listview. But how to I make the edititem template to appear at the bottom like the Inserttemplate
Its not available for the EditItemTemplate.
You'd have to actually save the original position, move the item in the data source itself (probably IList compatible), rebind the view, trigger editing on the new position, then swap the data item back to the original position.
I wouldn't recommend it. It's nonintuitive behaviour for users anyway; when I decide to edit something I should either be able to edit in place or edit on an entirely separate form. It's very rarely good UI design to shuffle items around while users are working on them, especially if you have any sort of scrolling/paging going on.

How to remove a textbox and put the dropdown box in asp.net

How to remove a textbox and put the dropdown box in asp.net
And the value that is used before in textbox, now it should take from dropdown box
You can use select tag for this. And can get the selected value in C# using the following code
Suppose cmb is the id of your dropdown box, then
cmb.Items[ cmb.SelectedIndex ].Value
can fetch the value selected in your drop down box and
cmb.Items[ cmb.SelectedIndex ].Text
can fetch the text selected
easiest way is to use jquery and jquery.jeditable plugin with it.

how to make an checkboxlist select only one item selected

i am using an checkboslist binding to a datatable.
but here i need to make user select only one item selected from checkbox list
is there way we can aachive this
either JQuery, javascript, c#
thank you
If the user is only allowed to select one item from a list, you should use radio buttons instead of checkboxes.
UPDATE:
If you have to use checkboxes then you can use the following code:
$("#myform :checkbox").click(function(){
$("#myform input:checked").attr("checked","");
$(this).attr("checked","checked");
});

ASP:ListBox | Multi Select | Keep selected values when selecting a new one

1) Have a listbox with 3 values out of 5 selected
2) When I click to select another value without holding CTRL button, it will unselect over values
How to make it keep other selected values if new value is selected?
This is going to sound like a snide answer, but I don't mean it that way. I just like to look for the simple solutions rather than the complicated onces.
The easiest way to get a control to have the behavior you want is to use a control that has the behavior that you want, rather than modifying the behavior of an existing control.
That said, if you want a list of items where a user can select a bunch of items off the list, and don't want to have to rely on them holding control, you're using the wrong tool for the job.
Use a CheckBoxList instead of a ListBox. If you want it to be scrollable, then set it in a div of a specific height, and set the style of the div to "overflow: scroll".
If you still want to use a ListBox you should use javascript and for each click event fired, you should check if the clicked element is selected/unselected and act accordingly. It's a little bit tricky but at least it is a solution for your problem.

Resources