1

I have an ObjectDataSource which uses a DataObjectType (Name). In this case EmpRow to pass update and insert parameters instead of passing individual parameters.

The ODS is used by the FormView which has two Multi Select ListBox controls. Because the ListBox controls will only pass one selected item, I need to properly add all selected values to the DataObject before the datasource updates.

So in the ObjectDataSource.OnUpdating event I want to iterate the selected items and adjust the proper values in the DataObject that is passed to the dataource update method.

My problem is that I can't figure out how to get a reference to the dataobject. It looks like to only way to it would be through the OrderedDictionary? Is that Right? Some how I need to reference the EmpRow object and update a couple of property values?

Any Ideas?

protected void dsDetail_Updating(object sender,      
    System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs e)
{

    OrderedDictionary od = (OrderedDictionary) e.InputParameters;
    IDictionaryEnumerator castRowEnum = (IDictionaryEnumerator)od.GetEnumerator();

    //Now I somehow want to create an EmpRow object from the 
    //passed DataObjectType of the datasource

    FormView fv = (FormView)FormView1;
    ListBox lstLanguages = (ListBox)fv.Row.FindControl("lstSpokenLanguages");
    ListBox lstSECPSTypes = (ListBox)fv.Row.FindControl("lstSECPSTypes");

    string strSpokenLanguages = "";
    string strSECPSTypes = "";

    foreach (ListItem item in lstLanguages.Items)
    {
        if (item.Selected)
        {
            strSpokenLanguages += item.Value + ",";
        }
    }
    strSpokenLanguages = strSpokenLanguages.Substring(0,                               
                                       (strSpokenLanguages.Length - 1));


    foreach (ListItem item in lstSECPSTypes.Items)
    {
        if (item.Selected)
        {
            strSECPSTypes += item.Value + ",";
        }
    }
    strSECPSTypes = strSECPSTypes.Substring(0, (strSECPSTypes.Length - 1));

    //now i need to assign these values to the proper data object properties
    //EmpRow.cSECPSTypes = strSECPSTypes;
    //EmpRow.cSpokenLanguages = strSpokenLanguages;
}
1
  • Ok, I figured it out. EmpRow empRow = (EmpRow) e.InputParameters[0]; Commented Nov 2, 2010 at 16:28

1 Answer 1

1

I have reached a solution which is to do:

EmpRow empRow = (EmpRow) e.InputParameters[0];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.