Can someone give me a bit of advice on the following (common) scenario.
I have a list of "Incident" records with an edit button for each
The Edit button opens up an "Incident" edit form for that record
The edit form contains a tab control with four tabs, each of which has a table for child (related) records: actions, documents, quotes and invoices
Take the first relation "actions". The table datasource is Incident: Action (relation).
A Add Action button opens a page with a form with datasource inherited action and type insert
I remove the Incident Id dropdown because I want this to be populated automatically from the parent record.
I add a text box and give it a value: #pages.Edit_Incident.datasource.item.Id
The text box is populated with the correct value
The submit button with OnClick Create New Item writes the record but does not persist the parent id or Incident_fk
What am I missing? This must be a common scenario.
If I enforce referential integrity in the model it doesn't save.
How can I persist the parent Id value to the Incident_fk field? I need to bind the text box to the datasource even though the page's datasource is correct
Related
I created a combo box field on the form. This combo box field gets the values from a SELECT query. Then I added Add Record button. When this button clicked I want to insert the record in a table. When I click on Add Record button, it doesn't insert record. I'm assuming because it doesn't know in which table to insert the record. How do I make Add Record button insert record in a table.
Joe
You probably used "Button creation assistant" from Access. It only makes you jump to the data entry form but it does not execute any SQL query.
If so, then you must first press the "Add record" button and then select the value you want to add in your combobox.
Be sure that your form is bound to the right table (ControlSource property). Then link your combobox to the field you are needing to and it should work.
I have created a simple web form on ASP.NET which includes a DropDownList with the names of all the records of a table (h. PhotoAlbums) in my database. When the user selects an album, all the items of this album (photos with tootlips) appear on the page in an order. I have carried out this by the aid of ListView control assigning a LINQ source as data source.
I would like by the selection of an album to grant the user the possibility to insert new items in the selected album at the same time and on the same page besides the appearance of the already existed items in the album. I think that I should merely use a DetailsView control and adjust this, so as to insert items. Is it though possible the DetailsView to appear after the selection of an album; not when the page is loaded initially? How?
If I understand your question,
You can Initially set the visible = "false" to the DetailsView. Then in your DropDownList OnSelectedIndexChanged method you can check the selected value and set the visible= "true". In your DropDownList you should set the property AutoPostBack="true"
Hope This Helps
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.
How have you gone about this problem?
Well, no suggestions. I did it eventually by, in the autocomplete selection, creating a nicely styled span. It's text contains the label, it contains an anchor element that I bind a click event to that removes the element if necessary, and I use the jQuery data API to store the ID value on the span. This span gets added to a container div, before the textbox that I'm using to autocomplete. I also bind a keyup event to the textbox to check for backspace - when it's pressed and the textfield is empty, then I remove the last autocomplete item. It's a little more complex though, since by the time the keyup event is pressed, the character that was being removed from the textbox has already been removed, so I store the actual value in the keydown event too using the jQuery API and check this in the keyup event.
There is a hidden field on the form, that I keep populated with a comma-separated list of ID values extracted from the span's data. This can be kept in sync when adding/removing items, or only when I post back - it's simplest to just clear it and repopulate it, and is quite efficient as far as I can tell.
When loading the page, the spans and hidden field must be generated.
Hope this helps anyone else looking for a solution.
I have a datagrid which shows the search reasult(time entered by the user preveiously)on a button click event depending uppon the input name or date enter by the user,i want to show a drop down list for a field selection like depertment whenever user want to edit the data in datagridiew,i am using access database & asp3.5.
You can use the Template Columns to specify a dropdown list for when you edit a datagrid. You can also do a bit more on the code side if you want to do things dynamically, but the Template Columns will allow you to override the standard textbox that shows when you edit.
I have a database with 2 records Id and Description.
What I want to do is try to bind this to a table so for example
<tr>
<drop down select list with ids available> <textbox>
</tr> <add button>
So the user can select an id from the drop down list, enter a description then click an add button next to this which will duplicate that block dynamically so they can enter as many as they like. What is the best way to go about this in webforms? Detailsview? I'm not sure how to make it dynamically add html blocks though? Any help would be appreciated.
pseudocode :
foreach description
create new tablerow
create a table cell in the row with the description as a label
create a table cell in the row with the id dropdown as a combobox
add the tablerow to the table.rows collection
the tricky part is accessing the data in your dynamically created table, but it shouldn't be hard to do as long as you set an identifier on each control that can be tied back to your data.
I'd stay away from any of the built in controls (i.e. DetailsView, FormView) for anything other than simple CRUD forms, as it's not much more effort to manually create your own data-entry forms.
Dynamically adding controls to an ASP.NET Webform (and have them work across postbacks) is quite a tricky one to get right, but in short you'll need to do something like:
Add a table server control which will store your dynamic rows.
Create a property (stored in ViewState or ControlState) to store a count of rows available.
Handle the appropriate 'add' button click event, to increment the count property and add a new table row, and child controls.
Inside an OnInit event, create the number of table rows stored in the count property.
Dynamically created controls aren't persisted across postbacks, so you'll need to create them on every postback during the pages OnInit method. As long as the controls are recreated in the right order and with the same ID's, then they will be repopulated successfully on postback.
Because you're dynamically adding controls, you may need to set the pages EnableEventValidation property to false.