Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange listbox behavior. New item won't show unless another item is added or page reloaded by exiting and returning
    primarykey
    data
    text
    <p>Here is what a portion of my screen looks like: <img src="https://i.stack.imgur.com/ExIqo.jpg" alt="Myscreen"></p> <p>The user can pick a choice from the drop-down list and click the add button. Here is the code for the add button:</p> <pre><code> protected void btnModuleAdd_Click(object sender, EventArgs e) { var selectedModule = ddlModsList.SelectedItem.ToString(); var graphicName = this.GraphicName; var xr = new GraphicModuleXRef(); xr.GraphicName = graphicName; xr.Module = selectedModule; // Take drop down list selection and add it to GraphicModuleXRef table. var context = new XRefDataContext(); context.GraphicModuleXRefs.InsertOnSubmit(xr); context.SubmitChanges(); } </code></pre> <p>Basically, it's taking the user's choice and writing it out to a table. This part works fine.</p> <p>In my Page_Load, I check whether IsPostback and, if it is, I run the code below:</p> <pre><code>private void LoadOtherModulesUsed() { if (this.GraphicName != null) { lbModules.Items.Clear(); var context = new XRefDataContext(); var q = context.GraphicModuleXRefs .Where(a =&gt; a.GraphicName.Contains(this.GraphicName)); foreach (GraphicModuleXRef gr in q) { lbModules.Items.Add(new ListItem(gr.Module.ToString())); } } } </code></pre> <p>This code reads from a table, finds all records that match the criteria, and adds them to the listbox.</p> <p>So, what I'm expecting to happen is for the page to reload and the listbox to be repopulated, including the new entry just added to the table. But, that isn't happening. The screen refreshes like it has reloaded, but the entry doesn't appear in the listbox. However, it IS there, it just can't be seen. If the user adds another entry, by clicking the Add button, the list 'rolls up' one row and the previous entry can be seen. But, not the new one. If the user exits from the screen and re-enters, all the entries in the listbox can be seen. It's almost like the listbox is too short to display all records, but I've tried different heights, with no difference.</p> <p>I'm wondering if anyone can point me in the right direction? </p> <p>Put simply, when adding a new item to the listbox, it isn't immediately visible unless another item is added, thereby 'rolling' the list up. Even scrolling the list with the scrollbar doesn't show the new entry until another entry is added. And, if you scroll the list up, you can see the prior entry. So strange!</p> <p>EDIT: Trying to describe this more simply:</p> <ol> <li>User adds item to listbox by pressing Add button.</li> <li>New item does not appear in listbox.</li> <li>User adds another item to listbox by press Add button.</li> <li>Prior item now shows in listbox if user scrolls listbox up.</li> <li>The newest item just added, however, does not appear unless step 3 is repeated.</li> <li>Also, exiting the page and then coming back in loads every item in the list and all is visible.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload