Newbie: Parent Child DropDownList writting to database

Newbie: Parent Child DropDownList writting to database

Post by boom » Fri, 14 Mar 2003 02:40:06



Does anyone have a code example that illustrates the following:
ability to populate dropdownlist from a database.  Change one of the
dropdown lists based on selection (parent/child).  Write this
information to the database.

I have successfully populated the dropdownlists.  The parent/child
dropdownlist is working.  When I got to write the information to the
database I get an error.

Exception Details: System.InvalidOperationException: Update unable to
find TableMapping['Table'] or DataTable 'Table'.

 
 
 

1. DropDownLists Parent & Child - Error capturing Child's SelectedItem

[also posted to microsoft.public.dotnet.framework.aspnet]
I have 2 dropdownlists on a webform.  The parent dropdown drives what is
displayed in the child dropdown.  Parent dropdown's autopostback is set to
true, so when the user changes the selecteditem, the page is reloaded and
the options for the child is updated.

The problem occurs after this postback, when the user clicks the button
which should grab the SelectedItem for each dropdown.  However, the
selecteditem for the child list is "lost".  This problem does not happen if
the user only changes the child list before clicking the button, ONLY if the
user changes the parent list and the autopostback occurs.

We (development team) are at our wit's end, and have tried all we can think
of so far.

Here is the code, I hope I stripped it down enough for readability.
"lstAssignedOrg" is the parent list, and "lstAssignedUser" is the child
list.

private void Page_Load(object sender, System.EventArgs e)
{
 if ( lstAssignedOrg.Items.Count == 0 )
 {
  FillAssignedOrgDropdown();  // calls the databind function for the
assignedorg list, straightforward
  FillUsers();
 }

private void Page_PreRender(object sender, EventArgs e)
{
 if ( lstAssignedOrg.Items.Count == 0 )
 {
  FillAssignedOrgDropdown();
 }
 FillUsers();

protected void FillUsers()
{
 lstAssignedUser.Items.Clear();

 if ( lstAssignedOrg.SelectedItem.Value != "" )
 {
  //
  // populates dropdownlist based on the lstAssignedOrg.SelectedItem
  //

  // this is more for the first time it loads, to set the list selecteditem
based on the value in the db
  ListItem li =
lstAssignedUser.Items.FindByValue(currentRequest.Assigned_User);
  if ( li != null )
   li.Selected = true;
 }

 lstAssignedUser.Items.Insert(0, "");  // in case there are NO users for a
specific org

private void btnAssign_Click(object sender, System.EventArgs e)
{
 // this calls a method which updates the database
 // with the values from the form
 // however, the lstAssignedUser.SelectedItem.Value is the blank value
ALWAYS
 // if the webform did an autopostback on parent control (lstAssignedOrg),
 // no matter if the you select a value from the child control
(lstAssignedUser)
 currentRequest.UpdateStatus( "Assigned",
lstAssignedUser.SelectedItem.Value, lstAssignedOrg.SelectedItem.Value );

2. What Init Dmi ???

3. parent-child dropdownlists?

4. searching for drivers Tandon Pac 286 removable disks

5. Treecontrol and "parent-child" database....

6. OpenVMS Software Product Description (SPD) Info

7. open form inside parent form even if it is called through child form of similar parent

8. PROLOG

9. BUG: Parent-Child expressions with new child records

10. Reading Child Row from a Datagrid displaying Parent-Child Realtionship

11. Writting Image to database

12. dataset with linked tables can't handle adding rows to parent and child, then updating?

13. "A Child has multiple parents" while writing dataset as xml