Problems passing data to ObjectDataSource

Posted on 2007-10-15
Last Modified: 2012-05-05
I have a fairly complex solution in order to combine a variety of Ajax Control Toolkit: ModalPopup with a TabContainer, as well as the usual GridView and DetailsView. The setup at a glance:
- GridView allowing for deletion and editing of rows, wrapped in an UpdatePanel.
- ModalPopup which is invoked when editing a row in gridview, and contains:
   * a DetailsView which uses an objectDataSource to get the editable data.
   *  the DetailsView consists of a TemplateField with two tabs in a TabContainer, allowing for more fields to be edited in a limited space.

When I push the "Save"-button in my detailsView everything seems fine since the modalPopup closes and the gridview updates itself. But, the new row does not contain any data. Every string passed by my DetailsView is emtpy.

Do you know of any solutions?

I would like to add that everything worked when I only used simple HTML to design my DetailsView. The problem occured when I added the TabContainer - but, I really want the TabContainer as it becomes easier to use.

Some more details about my problem:
Usually when you create a DetailsView it accepts that you define the same ID for multiple objects (like TextBox) as long as they are situated in different states of the DetailsView (like EditItemTemplate and InsertItemTemplate). When I use the tabs, this is not allowed, although I create the a new tabContainer in in each state of the DetailsView, like this:

So why does it all of a sudden return error messages telling me that my site already contains a definition for 'name', when the definitions are created in different states of the DetailsView?

Well, the most crucial agenda is still to make my tabs-detailsview-modalpopup to send the data via my ObjectDataSource. Remember that a regular detailsview-modalpopup will send the data, but this doesn't give me the correct design/layout for my input.

I really need some advice...
Question by:wahooo
    1 Comment
    LVL 5

    Accepted Solution

    One method I often use when I am having trouble with the automatic hierarchy of objects in ASP.NET is to directly address the wanted object with the "automatically" created instance name. Ok, when using runat="server" for any object in .NET, the object is automatically assigned a name depending on its location in hierarchy. Therefore a TextBox which you call "myTextBox" is placed inside a TabContainer (called Tab) and one of its TabPanels (ID = "TabPanel1"), then the generated ID for the TextBox would end up in the HTML to look like: ct100$ContentPlaceHolder1$Tab$TabContainer$myTextBox.
    Here the first ct100 refers to the page and ContentPlaceHolder1 refers to the actual ContentPlaceHolder you are adding the object to.

    So, in order to exploit this you have to change your parameters in your ObjectDataSource to a FormParameter, and point it towards the wanted Field:
    <asp:FormParameter FormField="ct100$ContentPlaceHolder1$Tab$TabContainer$myTextBox" Name="someName" Type="String" />

    Hope this works!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now