DataSource Controls :: Gridview Populated By ObjectDatasource Which Is Calling A DAL/BLL?
Jun 7, 2010
I have a gridview being populated by an ObjectDataSource (ODS). The ODS is calling a BLL to get information from a database table. The information returned is all determined by a participantID. This works fine normally.
The issue is that I'm getting an exception thrown when the participantID isn't listed in the database table; which is possible until their information is inserted and updated on this database table. The information is entered when someone visits a webpage, their information and date/time stamp is inserted/updated to this table, but not until then.
Do I edit my ODS or the BLL to check for a null return and handle this exception? How would I do this as well?
I am having some difficulty enabling sorting on a gridview that has data in it that has come from an objectdatasource.
The AllowSorting="True" function doesnt work for ObjectDataSource so I need to find a work around...I am guessing that I will need to do something in code in order to get this off the ground.
[URL] .... I Need to search record from GridView by using the textbox but not want to configure this with SQLDataSource Manually (Front End) therefore how to filter gridview from Codebehind.
This is not my solution. I actually compiled it here with proper example. So I don't take any credit for the solution. In the past I have used GridView to insert recordsbut not using ObjectDataSource. Mostly I did it by catching RowCommand event of GridView and call the appropriate function. This time I was adamant using ObjectDataSource to Insert in Gridview. GridView doesn't support Insert so it does not actually instantiate OBjectDataSourceView automatically for Insert operation
So here is the soloution, catch the RowCommand event of gridview, get the ObjectDataSourceView, create orderedDictionary, add entries to ordered dictionary, call insert function of ObjectDataSourceView instead of ObjectDataSource. Here is the RowCommand event of the gridview
I started learning LINQ, So i thought of just creating gridview with sorting and paging using objectdatasource using LINQ. So i got this link
[URL] which Brian Orrel tell us how to do using IQueryable Interface. but i have nearly 300 lines of stored procedure which joins nearly 20 tables. so i thought of creating a stored procedure and using that instead of IQuerytable.
I am really having a hard time trying to write something from scratch I created a 'Person' Class.Public Class Person
Private _FirstName As String = "" Private _LastName As String = "" Private _Age As Integer = 0 Public Sub New(ByVal FirstName As String, ByVal LastName As String, ByVal Age As Integer) FirstName = FirstName _LastName = LastName _Age = Age [code]...
I've created a query in the table adapter for retrieving customer name based on the first letter. The query is executed fine, and the output is the customer name and ID. A Customer BLL accesses this query, and sends the results to an objectdatasource. This control is configured to use this customer-by-letter query. However for some reason, this objectdatasource does not bind the name and ID, but instead all the other fields produced by the main query in the table adapter (i.e. name, address, phone, etc....).
I'm probably not configuring something correctly, but I'm not sure what.
My Business Logic Layer has AddItem method that add's to Items table in db along with an entry in Balance table.AddItem method uses two TableAdapters Items & Balance. Both these have corresponding Business Objects as Item and Balance.
Here is the AddItem method :
[Code]....
ASPX Page with DetailsView & ObjectDataSource
[Code]....
Now executing this page generates error as
ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'AddItem' that has parameters: _item, _balance, ItemName, GroupId, CategoryId, AuId, Rate, TotalStrScale, OffsStrScale, OffsAE [code]...
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.
I was woundering if its possible for me to check for accesslevel value from the database using objectdatasouce.... From my coldfusion experience... i could just use an "if statement"
e.g: <cfif> (datasouce.column = x) then <cfoutput> msg</cfoutput> </cfif>
Am not so sure about .net.... All i am trying to do is to check for one value on the db and i dont mind puting it on code behind... i just need a way..
Could I receive datatable or datarow as objectDataSource update function parameter? I need it because I need the datarow verison functionality to detect change for a column in the update function logic.this is what i had tried:
[Code]....
After I setup the update function in the ObjectDataSource , its DataObjectTypeName has a funny name
I have an objectDataSource which uses my stored procedure GetNotifications
And my GridView is bound to that objectDataSource
the only problem is that my stored procedure requires the variable @UserName and then returns the values for that username, but I do not know how to pass the variable to the objectDataSource, does anyone know the code for this?
I can get userName from HttpContext.Current.User.Identity.Name but how do I pass that to the objectDataSource?
I followd Brian Orrell LINQ tutorial for paging/sorting and created a gridview bound to an ObjectDataSource through a method call which gets data from adatabase. My form includes two buttons with a textbox next to each one of them. I need to be able to populatte th egridview depending on the button that was pressed, I cannot figure out how signal my method which button was pressed. [Code].... [URL]
I have an ODS control populating a Telerik grid. The ODS definition is pretty simple. It's set to call a method on a static class that has one parameter (entityID). I set this parameter in the OnSelecting event. When I test this, the world is a happy place and all is fine.
Then, I pass a query string to the page (which sets various unrelated values for the page, we'll say parameters X and Y). The page call's Telerik's radgrid.Rebind() event. When this happens, an error is throw from the ODS saying that the underlying method (the static data procedure) does not support parameters X and Y.
So, why is ODS thinking it should be using any querystring values at all when I have explicitly set the entityID parameter (of type Asp:Parameter)? How do I stop this from happening?
The Html:
[Code]....
The OnSelecting:
[Code]....
I see this odsList_OnSelecting being hit and the inspection of e.InputParameters only contains my expected single entry.
I am trying to update record in GridView. But ObjectDataSource is creating original_{0} and new vlaue object (exactly the same).ObjectDataSource.UpdateMethod is as follows
[Code]....
The paremeters ("original_ProductBO" and "productBO") in the above function are supposed to have different values since I am editing record in GridView and then updating it.I have the checked the query by hard coding parameter values and it works. In the ObjectDataSource_Updating(..) event, I cheked the parameters ("original_ProductBO" and "productBO") , I am getting the same values. Can anyone tell why tow parameters have the same values when I am editing record in GridView Code for the ObjectDataSourec and GridView is attached below
I have a dropdown list that uses an ObjectDataSource. The select method of the ObjectDataSource needs to localize the TextField, so i create a Dictionary<int, string> and use GetLocalResourceObject as such:
[Code]....
In the Local Resource file, there is status0, status1, and status2, all with a value (Deleted, Active, Inactive). The dropdown and object datasource like:
[Code]....
Now, if I use an ObjectDataSource and put the DropDownList's DataSourceID to it, I will get a null reference on the lookup to the GetLocalResourceObject. BUT If I manually set DataSource/DataBind on the dropdown list on Page_Load, it works fine:
[Code]...
OR If I move the status values to a global resource file and use GetGlobalResource instead of GetLocal, it works fine! Why can I not use an ObjectDataSource and LocalResourceObject in this way?
I have a page with a gridview with the liste of item in relation with another item (Same table) : Select * From Item where id IN ( Select idSonItem where idParentItem = @TheItem )
When i add an item from this grid i would like to link it with the current Item : So I insert the Item with the GridView InsertMethod then I do another Query an the ItemRelation with idParentItem as the courant Item and the Inserted Item as the idSonsItem !
so the question is : How to get the id of an inserted Item after i get executed the InsertMethod ?
http://msdn.microsoft.com/en-us/library/ms178538(VS.80).aspx ?I tried and got error as below, at clicking Update button in detailView
'/CaseExamples' 응용 프로그램에 서버 오류가 있습니다. ==> Server error in application program ObjectDataSource 'EmployeeDetailsObjectDataSource'에서 매개 변수 (LastName, FirstName, Address, City, Region, PostalCode, original_FirstName, original_LastName, original_Address, original_City, original_Region, original_PostalCode, original_EmployeeID)를 사용하는 네릭이 아닌 UpdateEmployee' 메서드를 찾을 수 없습니다.