locked
Drop Down List - Populate self and another field??? RRS feed

  • Question

  • User1503189645 posted

    I am working on my first stand alone application after working through tutorials for months to get my head around this. 

    I am working on what is called a condition report.  As part of the condition report we select an item from a drop down lost.  For example Pump.

    As part of the condition report we then type a description of the task this item does.  In this example you could write something like provides circulation of the water from the vessel as required.

    As can be imagined a lot of this is repetitive typing and something I try to minimise for the end user of the site.  Is there a way too?

    Use a second/third column of the drop down to populate a text box on the same form in the same session with a pre-written task description?

    Or is there a tidier approach to this issue?

    The task description should be inserted into a text box so it is pre-typed but alterable.

    Thanks

    Wednesday, February 8, 2017 3:45 AM

All replies

  • User-359936451 posted

    There are possibly lots of ways to do this. But first, you need to think about where the description is coming from.  If it really doesn't exist, what choice do you have other than to make your users type it in?  If these is an association of the "pump" and its "description" somewhere, than yes you could have a database that stores this data and the association and look it up each time a new pump is added to you your form. This is pretty basic stuff.

    Or if the content is newly added by users but will get reused later as new items are entered, than yes again, each entry could also be added to a database table and existing entries searched before the user is required to enter a new description.

    Check out this video on Channel 9 for some help...

    https://docs.microsoft.com/en-us/aspnet/web-forms/videos/aspnet-ajax/use-aspnet-ajax-cascading-drop-down-control-to-access-a-database

    Wednesday, February 8, 2017 4:01 PM
  • User-271186128 posted

    Hi dynamictiger,

    Use a second/third column of the drop down to populate a text box on the same form in the same session with a pre-written task description?

    Or is there a tidier approach to this issue?

    As march11 said, you could try to use Cascading DropDownList, please refer to the following articles:

    http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists-in-ASP.Net.aspx

    http://www.aspsnippets.com/Articles/Cascading-DropDownList-for-CountryStateCity-in-ASPNet.aspx

    Besides, you could also use DropDownlist SelectIndexChange event to populate the text box. In the SelectIndexChange event,  based on the dropdownlist selected value and get the description and populate the textbox.

    Best regards,
    Dillion

    Thursday, February 9, 2017 5:50 AM
  • User1503189645 posted

    Thanks.

    The database structure is:

    ID  Item  FunctionDescription

    1   Pump    circulates water

    2 Gas Heater  Heats water

    etc

    Drop down is how I would think to do it.  Holding ID as value, displaying item and posting function to text box.  This way the user can change to suit.  Just wasn't sure this was the best approach in ASP.  As I said very first venture on my own towards the direction I want to go.

    Thursday, February 9, 2017 6:40 AM
  • User-1509636757 posted

    I believe, you want to have a Dropdown that shows Item Names and ID in the Value field of the Dropdown. Upon selection of any Item, you wish to show Functional Description of the selected item in a Textbox input control. If so, then you can share what method you are using or want to use. There are lots of alternative, you can simply postback to server on SelectedIndexChanged even of Dropdown to call and write ADO.NET code to fetch Functional Description from database for selected ID in Dropdown. Or you can use Entity Framework and write LinQ query OR you may use jQuery ajax call to avoid full postback and use ADO/EF to fetch Functional description from database.

    hope that helps./.

    Thursday, February 9, 2017 6:53 AM
  • User-359936451 posted

    I would suggest you start developing and see how far you can get then post your code if you need further help. There is a lot of support here once you start your work and need help getting past certain pieces of the code.

    Thursday, February 9, 2017 4:14 PM