Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Problems passing data to ObjectDataSource

Posted on 2007-10-15
Medium Priority
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

Accepted Solution

royend earned 2000 total points
ID: 20081838
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

580 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