Use ObjectDataSource With Complex Objects And FormView Control?
Dec 30, 2010
I have a complex object. For example a SCHOOL object that contains a collection of PERSON object. How can I use the ObjectDataSource control with a FormView and flatten the complex object? An example display would be to display the school name and comma separate the students on the page. Is this possible?
public string Id
{
get { return m_id; }
[code]...
View 1 Replies
Similar Messages:
Jun 11, 2010
I'm trying to use formview in order to do insert of a new entity object (called Customer) Customer has a reference to another entity called Address. How can I fill both of them in the same formview?
View 1 Replies
Jan 6, 2011
I am developing a multi tiered web application in which I have a Formview control on the main page.
I want to use link control buttons for inserting and updating records.
What I am not sure about is how to point them at the correct methods in my data class.
I now that this will require me to drill down into the formview to access the formView
View 3 Replies
Apr 17, 2010
Consider a fairly complex business object. For the sake of discussion, let's think about a "ClassRoom" object - that will have some attributes which occur once, such as "capacity" and "area". It will also have some repeating attributes - perhaps "desks" which will itself be a collection of desk objects. The desk object will in turn have attributes such as "width" and "height".My example is more complex, but that should show where I am coming from. The business object, as you would expect, exposes methods to get the attributes in and out. There is also logic included to perform the underlying database updates. Of course, the necessary business validation is also in there.
In terms of binding to the ASP page, I will need to bind the attributes of "ClassRoom" to a set of fields on the page (using one method on the object). I will also want to bind the desks collection to a Repeater or GridView (using another method on the object).Presumably, I need to find a way to use a single instance of the ObjectDataSource so that the updates to the two (or more) disparate sets of data can be kept in step. I suspect that if I simply put two data sources on the page, I will get two instances and therefore no correlation between them.This can't be a unique problem, but I'm struggling to find any useful information.
View 3 Replies
Apr 16, 2010
Basically as the title of this thread states, I have a FormView that has a GridView inside it and my ObjectDataSource that populates this grid cannot access the Grid.
The Control Id needs to be the name of the Grid I want to access, however through the 'wizard' the Control parameter drop down cannot 'see' the grid I need, only the FormView that is in.
I have tried numerous ways to get round this and am struggling now..
I've tried the following...
ControlID="FormView.GridView1"
ControlID="FormView.FindControl("GridView1")
ControlID="<%= GetNameOfGrid %>"
and numerous other attempts that also failed that I now cant remember...
View 2 Replies
Mar 25, 2010
I have just run into a situation with a FormView control where any markup that is not given an ID and runat=server attribute is NOT rendered to the browser.
In other words, all of the extranneous markup (h#, fieldsets, legends, divs, labels, etc.) that are in my Edit Template DO NOT render to the browser at run-time. However, if I add an ID to any of those items and add runat="server" then they are rendered.
Has anybody every seen anything like this? Does anybody know what could possibly cause this?
View 2 Replies
Mar 24, 2010
I'm playing around with a asp.net page that's using the IScriptControl interface to pass data from the code-behind to the custom javascript object running on the browser.I'm passing a number of properties via IScriptControl.GetScriptDescriptors(), and they're all working fine, except for one.That one is a class derived from System.Collections.Generic.Dictionary<>. And even that one has been working for me, so long as the elements in the collection were scalars - ints, doubles, and strings. But when I tried to pass a member of a class, it showed up as a null object in the javascript. The class in question is marked [Serializable]. I changed it to a struct, and got the same behavior.It looks as if the serializer used in IScriptControl does a shallow copy.
View 2 Replies
Feb 22, 2010
I'm trying to bind the selections in a multiple selection SELECT, to an IList input in the controller.
<select name="users" multiple="multiple">
<option>John</option>
<option>Mary</option>
[code]...
View 2 Replies
Mar 3, 2010
I have a form which I use to create an issue. WHen you post the form, the form elements are that of a custom DTO. The DTO is then used on my POST method to create the new entity. That all works fine.
However, I want to add the functionality to add multiple issues at the same time from the same view. In effect, the user would click something like 'Report Additional Problem', and an extra set of form fields would appear (I will like use jquery for this, which I don't have an issue with). However, even with just leaving one set of form fields, the user should still be able to create just one issue. But if I habve my post method take a list or array of my DTO, it doesn't work.
Here is the post method before editing:
[Code]....
What I want to do is for this to take an array or list of NewIssueDto. I would then loop through each one in the list and create a new issue from it.
View 3 Replies
Jan 31, 2011
My DataTable is programatically generated, and contains objects of type JobInstance in the cells.
[Code]....
When I bind this DataTable to an ASP GridView, it only displays the first column. But if I remove the "typeof(Job)" when creating the column (the line with // !!!), the GridView displays all the columns by showing the result of JobInstance.ToString() in the cells. However, I have no access to the underlying JobInstance object, only the string values that are being displayed.
I need access to the JobInstance object when displaying the GridView (for example in the OnRowDataBound), because I want to access the fields inside JobInstance for each cell to determine formatting options, and add other links in each cell.
View 1 Replies
Apr 1, 2010
I have a data object where one of the properties is a collection of another data object. I never really figured out how to map this to a GridView, but I came up with a workaround. Now I am stuck and cannot figure out any way to do this in a ReportViewer.
Here is how I solved the GridView issue:
Say we have these objects:
public class BoysWithToys : List<BoyWithToy>
{
}
public class BoyWithToy
{
string FirstName { get; set; }
string LastName { get; set; }
int BoyNumber { get; set; }
List<Toy> FavoriteToys { get; set; }
}
public class Toy
{
int BoyNumber { get; set; }
string Toy { get; set; }
}
What I wanted to do was to map BoysWithToys to the GridView and present one GridView row per BoyWithToy record. Where there was more than one FavoriteToys record I wanted to list them in a bulleted list in the FavoriteToys column. I accomplished this by calling RowDataBound() for the GridView, casting the e.Row.DataItem to BoyWithToy, then looping through all of the FavoriteToys and adding each Toy to a bulleted list, then setting the column's text to that list.
I have no idea how to accomplish anything similar in ReportViewer. If I simply drag the BoysWithToys DataSource to the designer and run it, the FavoriteToys column shows '#Error'.
View 3 Replies
Feb 5, 2010
I have two business objects mapped via LINQ to tables. One of the objects contains an instance of the other object and share a key as an identifier.I want to retrieve Class A and within class A all of Class B's values as well. What I am doing is this:
[Code]....
[Code]....
This seems a little clunky, as in slow. Is there a better way to get the Class B (User) information without making a query every time?
View 4 Replies
Feb 20, 2011
I want to be able to update a model and all its collections of child objects in the same view. I have been referred to these examples: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx and http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ .
For example, I have an object Consultant, that has a collection of "WorkExperiences". All this is in an Entity Framework model. In the view, the simple properties of the Consultant object is no problem, but the collection I cannot get a textbox to show up for. I tried following the examples in the links above, but it doesn't work. The problem is, in those examples the model is just a list (not an object with a child list property). And also, the model again is an EF model. And for some reason that doesn't seem to work as in those examples.
[Code]....
This stuff with the EditorTemplate works fine in Phil Haack's sample project, which I downloaded to try, but here, with the EF model or whatever the problem is, I don't get any textbox at all. The table in the view is just there as a test, because in the table I do get the rows for WorkExperiences, whether I add an empty WorkExperience object or fill out its properties doesn't matter, the rows show up for each object. But again, no textbox...
View 2 Replies
Mar 26, 2010
I have this object in my server side:
[Code]....
Now I do this on the client side, to send a typed object to the server:
[Code]....
and actually it works. The problem is that I cannot find the way to stablish this property: "public ThingDetails[] details;"
View 7 Replies
Apr 2, 2010
I have a table in my database with a one to many relationship to another table, which has a relationship to a third table:
[Code].....
This seems to work fine. My question to you good folks: Is there a correct way to do this? I tried following the making a custom model binder per the blog link I posted above but it didn't work (there was an issue with reflection, the code expected certain properties to exist) and I needed to get something going ASAP. PS - I tried to cleanup the code to hide specific information, so beware I may have hosed something up.
View 1 Replies
Apr 8, 2010
i have the following scenario: one formview. when in editmode there is a child formview linked to the other by a column value. i need to take the value of one of the values of parent formview controls and set it to a textbox of child formview in insert mode. I wish to know which event should I use in codebehind to bind both controls? (that escenario will have paging and must keep the binding as if it was master detail)
View 9 Replies
Mar 27, 2010
I have an ObjectDataSource which refers to a class in my business logic. I have added this code
[Code]....
to a method within the class. That is the method specified as the UpdateMethod of the ObjectDataSource. The ObjectDataSource is attached to a FormView. I am seeing the following behaviour: Before I add the attribute, the update function works as expected; With the attribute, if the user has TestRole then the update works as expected; With the attribute, if the user doesn't have TestRole then the update method does not execute, but no exception is thrown. So, the functionality is restricting access to the method exactly as it should. However, no exception is thrown when access is denied.
As an aside, I have tried adding the attribute to the class rather than to the specific method. With that in place, I do see an exception (if the user does not have TestRole) as soon as execution goes anywhere near the class. This cannot be my final solution though as different methods in the class need different restrictions. Obviously, I don't want the update to fail silently, I need the exception to be thrown so that I can handle it.
View 5 Replies
Feb 22, 2010
I have a series of classes that loosely fit the following pattern:
public class CustomerInfo {
public int Id {get; set;}
public string Name {get; set;}
public class CustomerTable {
public bool Insert(CustomerInfo info) { /*...*/ }
[code]...
View 1 Replies
Jun 23, 2010
I've a form view with various field in edit and an object datasource where I've defined my update parameters that my update method takes. I've set some of the fields in the edit template to read only because I want them to display.
Unfortunately they are getting passed in as update parameters somehow to my objectdatasource.
So, it is generating update parameters that causes my method to not match.
How can I exclude these parameters from getting sent to update?
View 1 Replies
Nov 3, 2010
using an ObjectDataSource and a FormView.In the FormView I have a set of controls. When the FormView is in edition, I have in particular a ComboBox and a TextBox which are related as follows: when the ComboBox takes some special values, the TextBox must be read only or not. or the moment I get that behaviour as follows: the ComboBox triggers a postback when its selected item is changed and in the 'OnPreRender' of my page I get the value of the ComboBox and update the Readonly property of the TextBox accordingly.What I don't like with this method is that I don't use my object model which is consumed by the ObjectDataSource. The problem is simply that when the FormView is in edition there does not seem to be a way to get the instance of the object which is being edited. The 'DataItem' is null and I haven't found any way to automatically build a new object from the values in the controls to pass it to my business layer. Of course I could do the whole job myself by getting explicitly all the values in the controls, but that's not nice.
View 1 Replies
Aug 10, 2010
I'm using a FormView which has odsMain as the datasource. I am also using a dropdownlist which is being populated with objectdatasource odsddl.
I'd like to set the selectedvalue of the dropdownlist with the value contained in odsMain (the current record value for it). Is there any way this can be done?
View 6 Replies
Feb 24, 2010
I am working on an application and am attempting to use Linq with and ObjectDataSource but I only want to display/update 50% of the fields that are in the corresponding table. It appears to me that for this to work correctly, I need hidden fields on my form for all of the data fields from the table that the user cannot access. Is this the only way to do this? I have the following in my update method of my ODS:
[Code]....
The problem is, only the fields that appear on the form have data in them.
View 1 Replies
Mar 20, 2010
I have an ObjectDataSource giving me data similar to: OrderNumber OrderDate OrderValue OrderItems The first three are simple data types and the last has multiple occurrences of another class: OrderLineNumber OrderItem OrderQuantity The ObjectDataSource will only contain one row (which might make things simpler). So, there will be one OrderNumber, OrderDate and OrderValue; and then several occurrences of OrderItems (each containing OrderLineNumber, OrderItem and OrderQuantity).
I am displaying OrderNumber, OrderDate and OrderValue in the FormView - that work's fine, as expected. I have placed a GridView within the FormView and am failing miserably to get it to bind to OrderItems. I have tried the obvious things like specifying "odsWhatever.OrderItems" as the DataSourceID for the GridView, but to no avail.
View 4 Replies
Mar 25, 2011
I have a FormView bound to an ObjectDataSource that is bound to a business logic object. The business logic object has a Readonly field called "Id". When I try to update the formview, I get the following error message: The 'Id' property on the type specified by the DataObjectTypeName property in ObjectDataSource 'ObjectDataSourceNewsArticle' is readonly and its value cannot be set. How do I get the ObjectDataSource or the FormView to recognise that the id field is readonly, and to not try to update it?
View 3 Replies
Jan 22, 2011
I'm having a problem with a FormView control that I have bound to an ObjectDataSource. The problem is that the FormView control is not automatically filled in with the public properties of the object linked by an ObjectDataSource control when I select refresh schema. Everything compiles and I can add fields manually, but there are a lot of properties in the class and I do not want to deal with adding all the fields by hand. It's not the end of the world of course if I have to add them manually, but I'm bothered more by the fact that it doesn't act the other formviews.
Has anyone ever experienced a problem like this? I have other objectdatasource controls with other formviews that properly refresh their schemas. I noticed that in the objectdatasource control that is giving me problems, the DataObjectTypeName field is not automatically set as it is in the others. However, after adding it manually it still doesn't refresh the schema. I'm using Visual Studio 2010. Defined in .aspx page:
[Code]....
The SPFModuleBLL class contains the GetModule2() method which is shown here:
[Code]....
View 3 Replies