ASP.NET Data-bound Dropdownlist that permits manual entry also? - asp.net

I am not a .net programmer but I can write bits and pieces that I need, however, I have been having trouble working out the best way to achieve something for a website I'm altering.
I basically need to have a drop down list which is bound to a certain SQL call (already in place) but I also need the ability to manually type into the drop down list for items that do not exist. These items do not need to be entered into the SQL (I can handle the additional data separately) but I cannot find a way to type inside a drop down list while it is bound to a datasource.
Some entries in the datasource (SQL table) are used for one thing, but then a text string needs to be entered for optional entries which do not exist within this SQL table.
Does anyone know how I can achieve this or maybe another similar control can be used that offers this kind of functionality?
**Update to be more clear:
I need this at runtime. For instance, I do not need this to be within code I actually need the control to accept user input when someone is on the webpate.
Imagine a shopping list and all the items are within the drop down list then the user wants to add another item to the shopping list so they just type it into the drop down box and submit the page and its value will be used instead of an existing item.

As suggested by David, Telerik ComboBox provides that functionality.
Other ways, to use an ASP.NET and jQuery for implementing that functionality.
Using TextBox permits manual entry and using jQuery UI AutoComplete widget to bind required items.
jQuery Autocomplete and ASP.NET
TextBox AutoComplete with ASP.NET and jQuery UI
3 Different Approaches for Implementing the JQuery Autocomplete with ASP.NET

Related

Is there a pattern I can use to edit dropdown lists in an MVC3 application?

I am looking for a general, reusable UI pattern I can use for editing the content of dropdown lists in my MVC3 app. That is, some of the Id-Name pairs used to populate dropdowns for edit views exist only for this purpose, and have no dedicated controller-view setup themselves. E.g. Industry and Sector for course modules. Each list is only an Id-Name structure, but Sector has an IndustryId value as well.
Now I really don't want to use the standard scaffolded views for these, i.e. create,edit, and list with links, but I can't help wondering how best to improve on these. Should I bind each list to an editor that just renders a an EditorFor textbox for each item in the list, with jQuery to add a new item or delete an item? is there some established way of doing this?
NOTE: This is not about loading a dropdown list. It's about loading the values for a dropdown list into a view for editing them, to control what appears in the dropdown list when it loads by whatever means.
I don't know if there's a pattern per se, but we deal with this sort of thing as well (dozens of lookup tables with the same structure) and we use simple pages with a jqGrid. The editing is live in the sense that changing a row causes an Ajax call to the controller to modify the lookup value itself. Works fairly well. We ended up having a dedicated view for each of the editable lookup tables (not all of them are) but it would have been simple enough to use the same view, controller and client-side script for all of them.
You can use jQuery, and jQuery UI to customise your dropDown lists

ASP.NET Design Issue: what is the best asp.net control for creating a table with 15 properties?

I am a new ASP.NET developer and now I need to develop a data entry system with 15 fields that allow the admin of the system to enter some data under each one of these 15 properties. From what I learned in ASP.NET tutorial, I think the best control is the ListView control in order to give the admin of the system to enter a new field if he wants in the future. My problem now is the following:
How to divide these 15 fields into two columns? Because all what I see about using ListView is putting all of the properties at the first row and the entries will be underneath of them. What I want is to create a list with two columns of properties and two columns for the entries
I'm not sure that a ListView makes sense from your description. Are your administrators updating the same properties on different objects? Like most of the ASP.NET controls in its class -- the Repeater and GridView are other similar examples -- the ListView is meant to create several rows of identical information based on an HTML template you provide.
If your administrators are creating or updating:
The same property for different objects, then the ListView, Repeater, or GridView would be fine.
Different properties for the same or different objects, then you need a more traditional form with normal data entry controls (like the TextBox, HtmlSelect or DropDownList, CheckBox, etc.)
I would use a more liberate approach and code the fields my self into the view you'd like.
At first it might take more time, but after that your would be able to control the look of it much quicker and easily.
Using a listView you can build your edit/input gui as you'd like - a table or any other way. If really must divide into 2 columns - you could just put a label and then the field just underneath it. 7 on one side and 8 on the other.
If you're looking to use the edit features of a data control, you could create a custom item template for your data control (be it a gridview or whatnot) that has a table and each of the properties (I assume all 15 are conisidered 1 row of data). Bind your single row to the data control and it should work. You could even have different template views for display and editing using the templates.

How can i create a submitable form that contains dynamically added and removed controls

I am trying to create a form that is made up of controls with values that represent an entity with multiple child entities.
The form will represent a product with multiple properties where the user will then be able to create options with multiple properties which in turn be able to create multiple option-items with multiple properties.
My question is what is the best approach? Can i use ajax to avoid postbacks and having to rewrite the controls to the page? If i dynamically add the controls in the form of table rows or grid rows will the data/control values be available in the code-behind when i submit?
This is an age old question.. the last time i had to do this was .Net 2.0, pre-ajax (for me) and i was forced to recreate all the controls on each post back. thanks!
If I'm understanding your question correctly, you want to dynamically change form elements depending on some kind of selection criteria without refreshing the page? Javascript can do this for you. If your elements rely on data from somewhere, such as options for a select menu, then yes you will have to use an ajax request to populate those. If they are static options, then pure javascript will work for you. And though the source won't indicate your generated elements, they will indeed be available for a submit. I hope this helps.

How to make a general form in Flex to deal with Entity CRUD?

I would like to create a general form so that it can deal with creation/read/update of an entity. When creating an entity, it may only contain a subset of all fields; when updating the entity, it may contain a different subset of fields; and when reading the entity, none of the fields are editable. Anyone with experience in designing such a form in Flex? Thanks in advance.
I was frustrated with the quality of the flex forms as well, especially managing the validation, so I wrote my own form control. It's a bit haphazard and buggy at times so it's not ready for sharing, but I'll cover the ideas:
Separated into a layout part and a data part, matched by keys. Both are basically combinations of AS3 Objects/Arrays containing the properties I need.
Describe all the possible visible elements in the layout, the validators needed, visual properties, labels ,etc... Every element in the layout is an Object in an Array. The primary array is ordered and displayed via a VBox. Any nested arrays are displayed in a nested HBox (e.g., useful for radio options).
The data part of the form is where you can set initial values, "editable" properties, "model" properties (for combo boxes), things like that. The data structure is an Object hash where the keys map to elements in the layout. If an entry from the layout does not exist in the data definition, it does not appear. This allows you to easily hide sections you don't want to show.
Has an errors sections where validation or server errors can be displayed.
Has a collect function that collects all the data into an object hash.
Has a validate function to control when the validators are triggered.
Non editable fields show up as labels.
Basically I've implemented my own "Form" control, and each entry in the layout (when displayed) becomes a custom "FormItem" control that will be whatever type the layout described. ("text","combo","heading",...)
Hard to describe without visual examples and some code, but that's the basic idea. You're on the right track thinking that you need your own control. There's too much hand-holding required for the generic forms, and lots of redundant code.
Check out Rocket Framework .. you gonna love it..
Want to automate winforms? not just CRUD, this help creating any type of winforms controls. The Rocket Framework for WinForm (using .net c# 4 ) provides a set of easily utilizable generic library to seemlessly develop 'form based' application/ control / custom controls for .Net.

Can database fields be dragged and dropped (as textboxes, not a gridview) into an ASP.Net form?

In VisualStudio, when you drag and drop a table or an individual column from a data connection in server explorer, a gridview is created.
What I want to be able to do is drag and drop the columns to make a quick and dirty detail form to display an individual record. Is this possible in any way?
An even better way to do this would be via a custom T4 or LLBLGen template but I have no clue how to do this.
Any other suggested approaches?
UPDATE: A DetailsView is the type of thing I am looking for, in that you can select a data source and the specific columns you want, but I'd like to be able to have manual control of the layout and formatting after the initial drag and drop.
I suggest binding a DetailsView to the table using a data source (SqlDataSource) instead. You might find these tutorials, especially this one helpful.
In response to your update, have a look at the FormView control. It gives you complete control of the layout using templated sections.
There appears to be literally no way to do this in VS that I have come across.

Resources