DataSource Controls :: Pass Object As SessionParameter In ObjectDataSource?
Dec 28, 2010
Is it possible to pass a domain object as session parameter in an ObjectDataSource. I'm doing this:
<asp:ObjectDataSource ID="ParticipantsDataSource" runat="server" OnInit="SqlDataSource_Load"
SelectMethod="LoadParticipants" TypeName="SB.Web.units.Players">
<SelectParameters>
<asp:SessionParameter Name="user" SessionField="User" Type="SB.BusinessLogic.DomainEntity.User" />
</SelectParameters>
</asp:ObjectDataSource>
But I get the error message that I can't create an object of the type System.TypeCode from the string containing SB.BusinessLogic.DomainEntity.User for the property Type.
View 1 Replies
Similar Messages:
Mar 31, 2011
how to pass an object to the selectmethod of the objectdatasource control?
View 2 Replies
Jul 20, 2010
I am trying to get an asp:SessionParameter of a SelectParameters, to use a property of an object in session
instead of having a string in the session like Session["CustomerID"]
Something like Session["Customer"] where the property is ((Customer) Session["Customer"]).CustomerID)
My code:
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:DBConnectionString %>" xmlns:asp="#unknown"> SelectCommand="SELECT * FROM getStoreCustomers (@customerID,@week,@day)"
ProviderName="System.Data.SqlClient">
<selectparameters>
<asp:sessionparameter name="customerID" sessionfield="Customer" /> ?????? (what is the syntax to pass the property here?)
<asp:controlparameter controlid="ddWeek" defaultvalue="-1" name="week" propertyname="SelectedValue" /> <asp:controlparameter controlid="ddDay" defaultvalue="-1" name="day" propertyname="SelectedValue" /> </selectparameters>
The class I use is like any other class (but serializable)
[Serializable]
public class Customer
{
public int CustomerID
{
get;
set;
}
}
View 2 Replies
Sep 10, 2010
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?
View 7 Replies
Oct 25, 2010
I have an objectDataSource to retrieve data and fill a listBox on edit
I created a BLL method to get the data and set the controlId to the detailsVeiw control but the id is not passed throuh to the bll class
this is my code:
[Code]....
View 1 Replies
Mar 14, 2011
[Code]....
[Code]....
The GetList method is as folllowing:
[Code]....
Now i can populate my gridview trough code by this: //gvwDiensten.DataSource = new BindingList<diensten>(dataManager.GetList<diensten>().ToList());But i would like to use an objectdatasource, so i created this:
[Code]....
</asp:ObjectDataSource>
But when running the page i get:
ObjectDataSource 'dsDiensten' could not find a non-generic method 'GetList' that has no parameters.
View 5 Replies
Mar 27, 2011
how to pass parameters to the selectmethod property of the objectdatasource control.
View 1 Replies
Mar 5, 2010
I would like the ObjectDatasource insert and update data methods to return the inserted or updated object like LinqDataSource do.
View 2 Replies
Mar 30, 2010
I'm trying to use an ObjectDataSource's SelectMethod() to retrieve a result set from a sql server database to populate a data table with various stored procs that have any given number of parameters. My approach is to pass an object which contains the stored proc name and information about its parameters into the SelectMethod(). My issue is that I don't know how to actually set the default value. Here is the code I have so far:
ObjectDataSource1.DataObjectTypeName = "WebApplication1.Children";
ObjectDataSource1.TypeName = "WebApplication1.Children";
ObjectDataSource1.SelectMethod = "Select";
Parameter odsParameter = new Parameter() { Name = "storedProc", Type = TypeCode.Object };
// How do you set the default value to reference an object?
ObjectDataSource1.SelectParameters.Add(odsParameter);
namespace WebApplication1
{
public class Children
{
public DataTable Select(object storedProc)
{
// do stuff here and get db values.
}
}
}
The default value of a Parameter object is a string type. Does anyone know how to set the default value with an object or how I can pass an object into the SelectMethod?
View 2 Replies
Jan 11, 2010
I have FormView that has a DropDownList
this DropDownList takes its list from a sqldatasource that has SessionParameter as parameter.
after loading the page if i changed the value of the session an error get fired !!
the Error is "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
When i click on the GOOOO button the error occures
My Code is
[Code]....
My other code is
[Code]....
View 9 Replies
Mar 14, 2010
How do I make ObjectDataSource work with singleton Business object? My singleton business object is defined in Global:
[Code]....
I get an error:The type specified in the TypeName property of ObjectDataSource 'objThreads' could not be found.
View 2 Replies
Oct 18, 2010
I have an ObjectDataSource that I want to perform updates using a business entity i.e. Type="Object"). Since the values for the entity are within a user control, I have stored a reference to the control in Session and in the updating event, set the new instance to the value of the entity from the user contol property (which also pulls values from the form viaother properties of the control):
Protected Sub MasterDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles MasterDataSource.Updating
Dim entity As New Login()
Dim accountControl As AccountInfo = TryCast(Session("AccountCtrl"), AccountInfo)
entity = accountControl.Entity
e.InputParameters.Add("entity", entity)
End Sub
And here's the markup for the datasource:
<asp:ObjectDataSource ID="MasterDataSource" runat="server" EnableCaching="true" CacheDuration="10"
SelectMethod="SelectAll" UpdateMethod="Update" TypeName="Data.DAL.LoginDAL">
</asp:ObjectDataSource>
My question is, how can I get the update method to pass this entity to the update method in my BLL class? It seems the Update method requires an ID or reference to the original object to use in determining whether any changes have taken place, but I don't really want to do this. In other words, I just want to use the Update event on my ObjectDataSource to pass my entity to the method ("Update") I set as a property and then let this business method handle the update of the data. Shown below, is the BLL update method I want to call:
Public Overloads Function Update(ByVal entity As Login)
If entity Is Nothing Then
Throw New ArgumentNullException("entity")
End If
MyBase.Update("UpdateLogin", entity.Username, entity.Password, entity.FirstName, entity.LastName, entity.Role, entity.Region, _
entity.Email, entity.Title, entity.TierID, entity.Street, entity.City, entity.State, entity.Zip, entity.Mobile, entity.Phone, entity.Fax)
End Function
When I try to call this as it stands now, I get an error: ObjectDataSource 'MasterDataSource' could not find a non-generic method 'Update' that has parameters: ID, entity. Previously, I'd set up a long list of parameters of basic data types (string, int, boolean), but this is rather cumbersome and I was hoping to use an entity for this (FYI, I also got the same type of error when I tried this approach, but with the ID as the
last parameter in the list). Perhaps what I'm doing here is atypical to how the ODS is normally used?? Has anyone done something like this successfully?
View 1 Replies
Jun 30, 2010
I have a gridview inside a user control bind to an object datasource. Now I want to bind the object datasource with a parameter from parent page.
For this purpose I defined a public property in user control but how do I pass it with object datasource ?
I am calling from parent page like
myusercontrol.parameter=querystring["id"];
How to bind object datasource with my parameter ?
View 4 Replies
May 6, 2010
I want to pass the Array ( object[]) or Structure data type value to the store procedure through
ibatis .net. I can do same by commandtext using SQLDBType.Structure. I am using Table value function in sql server 2008 and .Net 2010.
[URL]
View 2 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
Mar 9, 2010
I am trying to update record in gridview using ObjectDataSource (with conflict detection)The following is the ObjectDataSource
[Code]....
Update Method is as follows
[Code]....
In ObjectDataSourceProducts_Updating(..) event , I am checking objects which are being sent to UpdateProduct(..) method. I found that both the objects " original_ProductDB and productDB " have the same the values. When I click "Update" in GridView after entering new value, ObjectDataSource is not picking new value
[Code]....
GridView is as follows.
[Code]....
ProductBO is as follows
[Code]....
View 3 Replies
Jun 24, 2010
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]...
View 1 Replies
Jan 26, 2010
I have set the objectdatasource in the web form. Does I need to check anything as I find that method "objProductSuppliment_Inserted" does not run??
-----------------------------------------------------------------------------------------------------------
<asp:ObjectDataSource ID="objProductSuppliment" runat="server"
OnInserted="objProductSuppliment_Inserted"
TypeName="BLL.WMS.ProductSuppliment"
[code]...
View 6 Replies
Jan 16, 2011
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.
The BLL code:
[Code]....
The .net code:
[Code]....
View 4 Replies
Jan 4, 2011
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]...
View 1 Replies
Jun 22, 2010
I'm creating an ASP.net website with 3 layers (Presentation, BLL and DAL).
BLL and DAL are 'class library'. DAL has a typed dataset. Presentation refers BLL and BLL refers DAL.
I wanna populate my GridViews with ObjectDataSource, but it only shows me the DAL. Nothing from BLL...
What am I doing wrong?
View 2 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
Jul 20, 2010
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..
View 4 Replies
Sep 9, 2010
created my own stored procedure in SQL Server for my aspnetdb database which is :
view plaincopy
to clipboardprint?
View 1 Replies
Apr 14, 2010
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
[Code]....
View 3 Replies