DetailsView EditItemTemplate CheckBoxList2 bound and Related to CheckBoxList1

Discussion in 'ASP .Net Web Controls' started by MikeR, Aug 25, 2006.

  1. MikeR

    MikeR Guest

    Hi all.
    Patience is a virtue!! Please read on!
    I have a DetailsView that is bound to an ObjectDataSource (ods) whose
    selectparameter is set when a row in a GridView is selected. Works fine. I
    see the record in the DetailsView. In the DetailsView i have a
    templatefield named SystemCode with a DropDownList(ddlSystemCode) thats
    bound to an ods (odsSystemCodes) and SelectedValue='Bind("SystemCode").
    Works fine. I have another template field named TrainCode as a
    CheckBoxList(cblTrainCode) that is bound to an ods (odsTrainCodes) and whose
    SelectedValue='Bind("TrainCode"). When the user presses the Update Command
    link, everything works fine. The ddlSystemCodes selected value is the one in
    the database record. The TrainCodes CheckBoxList shows the correct checkbox
    checked for the TrainCode in the database.

    Now, in Edit Mode, if i select a different SystemCode from ddlSystemCode,
    what i want to have happen is to have the TrainCode CheckBoxList show the
    list of TrainCodes corresponding to the selected SystemCode. I'm trying to
    do this by putting code in the ddlSystemCode's SelectedIndexChanged event to
    change the SystemCode Select Parameter of the TrainCode ods (odsTrainCode).
    When i do this i get this error:
    "DataBinding methods such as Eval(), XPath() and Bind() can only be used in
    the context of a databound control".
    Is it because of the SelectedValue='<%#Bind("Traincode")%>' in cblTrainCode
    Any ideas, workarounds or better approaches would be greatly appreciated!
    MikeR, Aug 25, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.