Accessing An Object That Implements SelectMethod For ObjectDataSource?

Nov 8, 2010

Is it possible to access an object that is used by ObjectDataSource to retrieve records? For example,

<asp:ObjectDataSource ID="MyDS" runat="server"
SelectMethod="getUsers"
TypeName="DataSources.UserDS"
SelectCountMethod = "getUserNum"/>... </asp:ObjectDataSource>

UserDS class has getUsers that returns DataTable and getUserNum that returns int, this part works as it's supposed. But I wonder if can access the instance of UserDS somehow (not underlying DataTable)?

View 1 Replies


Similar Messages:

DataSource Controls :: How To Pass An Object To The Selectmethod Of The Objectdatasource Control

Mar 31, 2011

how to pass an object to the selectmethod of the objectdatasource control?

View 2 Replies

C# - How To Use Global Variables In ObjectDataSource.SelectMethod

Sep 10, 2010

I'm using ListView + DataPager + ObjectDataSource mix.

In the implementation of my SelectMethod of an ObjectDataSource I'd like to access a global variable set in the PageLoad() event (the method will return just the proper number of items per page). Although the variable is initialized in PageLoad() it appears to be null in SelectMethod. How can I change that?

[Code]....

View 4 Replies

DataSource Controls :: Specify Two Different Methods As SelectMethod Of ObjectDataSource At Two Different Events?

Apr 13, 2010

Can we specify two different methods as SelectMethod of ObjectDataSource at two different events?

I need my Objectdatasource to get filled with one method while at button click event I want to fill it with other overloaded method.

Both the methods have same name and return same data type but they have different input parameters.

View 6 Replies

DataSource Controls :: Pass Parameters To The Selectmethod Property Of The Objectdatasource Control

Mar 27, 2011

how to pass parameters to the selectmethod property of the objectdatasource control.

View 1 Replies

SelectMethod In ObjectDatasource Getting Called Multiple Times With Multiple Datapagerfield?

Oct 7, 2010

so here is the setup. I am building a page that has a listview, a datapager, and 3 datapagerfield (2 x NextPreviousPagerField, 1 x NumericPagerField), and a objectdatasource to tide all of this together.

It was all working fine until I put a breakpoint into the SelectMethod specified in the objectdatsource control. It seems like that for each datapagerfield control, it is calling the selectmethod and selectcount method. Hence, whenever a user paged, it calls the database 6 times instead of 2 (I don't have caching turned on atm). If I remove one datapagerfield, it will remove 2 calls.

Now this is build in asp.net 3.5 SP1 in VS2008. When I copied the same code files to a asp.net 4.0 VS2010 solution, it duplicate call seems to be gone.

Is this a bug in asp.net 3.5 SP1?

View 1 Replies

Accessing BLL With ObjectDataSource - Could Not Find A Non-generic Method?

Nov 25, 2010

I'm a starting C# programmer and I'm experiencing the following problem.I've created a dataset in Visual Studio With a table for persons making use of two table adapters, one for selecting all persons and one for selecting one person at a time filtered by the personID (Guid). This is a seperate project of my solution. After that I created a new project for the Business Logic Layer

private PersonenTableAdapter personenAdapter = null;
protected PersonenTableAdapter Adapter
{get....}
[System.ComponentModel.DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType.Select, true)]
public DAL.Testdatabase.PersonenDataTable GetPersonen()
{...}
[System.ComponentModel.DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType.Select, false)]
public DAL.Testdatabase.PersonenDataTable GetPersonenByID(Guid ID)
{...}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public bool updatePersoon(string Voornaam, string Achternaam, string Geslacht, string Adres, string Huisnr, string Postcode, string Plaats, string Telnr, string GSM, string BSN, DateTime? CreateDate, string CreatedBy, DateTime? LastModifiedDate, string LastModifiedBy, bool? Actief, DateTime? DatumInactief, Guid ID)
{...}
When issueing the Update method using a detailsview with an Objectdatasource i get the following error.
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'updatePersoon' that has parameters: Voornaam, Achternaam, Geslacht, Adres, HuisNr, Postcode, Plaats, Telnr, GSM, BSN, CreateDate, CreatedBy, LastModifiedDate, LastModifiedBy, Actief, DatumInactief, original_ID.

View 1 Replies

DataSource Controls :: Accessing The Data In The Objectdatasource?

Feb 14, 2010

I have a webpage that uses a formview. The formview gets the data from the objectdatasource which connects to a query in a table adapter.

I wanted to add a hyperlink in the page right below the formview that will "hyperlink" to another page passing parameters. Those parameters are values from the formview.

Can I just access the parameters of objectdatasource from outside the formview as follows?(it isn't working)?:

<asp:HyperLink
ID="HyperLink215"
NavigateUrl='<%# Eval("VIN", "Contact.aspx?Subject={0}") %>'
runat="server">Contact Us Regarding This Vehicle</asp:HyperLink>

If not, can I access those parameters in codebehind and do a redirect from there? How do I access the data of objectdatasource from codebehind? If I can do that, I could just put a button. Then in the button's click even, I could do the redirect.

View 4 Replies

Web Forms :: Accessing Control In Usercontrol / Error: Object Reference Not Set To An Instance Of An Object

Apr 19, 2010

In the same Code behind file I have:

// This works

Label lblTopNavBarInfo = (Label)Master.FindControl("lblTopNavBarInfo");

lblTopNavBarInfo.Text = "Currently Serving: + FirstName + " " + LastName ;
// This compiles but throws an error in the browser

LinkButton lnkBtnProductsOwned = (LinkButton)LeftNav_CustServ1.FindControl("ProductsOwned"); // The Control is visible

lnkBtnProductsOwned.Enabled = false; // Error: Object reference not set to an instance of an object.

View 6 Replies

Data Controls :: Accessing DropDownList In GridView Row - Object Reference Not Set To Instance Of Object

May 30, 2013

I have this part in the Gridview.

<asp:TemplateField HeaderText="Student">
<ItemTemplate>
<asp:DropDownList ID="ddl" OnSelectedIndexChanged="ddl_IndexChanged" runat="server">
</asp:DropDownList>

[Code]....

After the change, when it is to bind data, I get this Exception message. Why?Object reference not set to an instance of an object.

View 1 Replies

C# - ObjectDataSource Return Object From Cache?

Jan 13, 2011

Is there any way to return object from Session when Select is called on ObjectDataSource? Specifically, I have Products object and saved in Session. Now on another page I have ObjectDataSource which will call same bussiness object method to get Products object. Here I want to hook up any event like Selecting and I would like to return Products object from Session to Select method of ObjectDataSource.

View 1 Replies

C# - How To Access ObjectDataSource Object After Bind To GridView

Feb 4, 2010

I have a GridView, I bind it to ObjectDataSource. ObjectDataSource takes data from a database's table. Each row in table has unique ID.

I have a button in each row of GridView that should remove this row from database. My ObjectDataSource returns Object, this returned object contains ID (and some other information, like name, user etc.) however I do not show this ID on my grid.

how can I get these ID after user chooses to delete row, I need to know what I should remove.

View 2 Replies

C# - How To Catch Exception Occurred In DAL Of ObjectDataSource Object

Sep 1, 2010

I have ObjectDataSource and GridView on one of the pages of my asp.net web project.

To initialize ObjectDataSource i use Init event:

protected void ObjectDataSource1_Init(object sender, EventArgs e)
{
ObjectDataSource1.EnablePaging = true;
ObjectDataSource1.TypeName = "CustomerDataSource";
ObjectDataSource1.DataObjectTypeName = "Customer";
ObjectDataSource1.SelectMethod = "GetCustomers";
ObjectDataSource1.UpdateMethod = "Update";
ObjectDataSource1.SelectCountMethod = "GetCustomersCount";
ObjectDataSource1.MaximumRowsParameterName = "maximumRows";
ObjectDataSource1.StartRowIndexParameterName = "startRowIndex";
}

Somewhere in DAL:

public static List<Customer> GetCustomers(int maximumRows, int startRowIndex)
{
try {
... some select to database here...
}
catch (Exception ex)
{
Utils.LogError(ex);
throw ex;
}
}

Now let's imagine that GetCustomers for some reason throws an exception. How could i catch this exception and handle it? I know i can use Application_Error, but i would like to catch this exception somehow on my page and show some friendly message to the user.

View 1 Replies

How To Get The Inserted Id Or Object After An Insert With The FormView/ObjectDataSource Controls

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

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

Modify Child Object During Gridview OnUpdate Using ObjectDataSource?

Sep 2, 2010

Backgroud: I'm using NHibernate for my model layer, and I have a HTTP module taking care of instantiating the session at the beginning of each request and cleaning it up at the end of each request (i.e. Session Per Request). In this case, I have two object types:

ParentItem - an object with a bunch of properties and a collection of ChildItems. ChildItem - an object with properties including a DateTime (EffectiveDate) and an unenforced FK pointing to a completely different database. The ChildItem class contains a reference back to the parent as well (many-to-one) While the ParentItem has multiple ChildItems in its collection, I'm only generally interested in the latest ChildItem in the collection.

Desire: Want a databound control (GridView or ListView, I don't care which) that allows me to Add/Edit/Delete ParentItems from my datasource. I also want to have the ability to set a new "latest" ChildItem as part of the edit/update.

Issue: I can't seem to access the underlying DataItem from the GridView/ListView in the OnItemUpdating handler (which isn't unexpected, since the data is now in the viewstate). What I thought I could do would be to load a ParentItem from my session using the ID from the databound control, create a new ChildItem, add it to the ParentItem, and then save the ParentItem. Since NHibernate caches the data, the load should give me a copy from cache (no roundtrip to the DB) and I'd either be doing this before the ParentItem was saved back (thus no changes committed to ParentItem, just to ChildItem) or after (thus the cached version is still the same, and my new object will match the updated version). What I get when I do this (for ParentItemID=1):

a different object with the same identifier value was already associated with the session: 1, of entity:

NameSpace.ParentItem

on the line:

Session.SaveOrUpdate(parentItemInstance);

View 1 Replies

DataSource Controls :: Objectdatasource Return Inserted Object Like LinqDatasource Do?

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

DataSource Controls :: Passing Object To ObjectDataSource.SelectParameters Collection

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

Visual Studio :: DataSet Not Recognized As Buesiness Object By ObjectDataSource?

Nov 15, 2010

I have an ObjectDataSource in Visual Studio 2008. I have a DataSet defined with a TableAdapter. However, when I go to select the Table Adapter to use in the ObjectDataSource, nothing shows up. I double checked that the DataSet is in fact in the App_Code folder. I do not know what else to try. The following code is the ASP code for that ObjectDataSource:

asp:ObjectDataSource
ID="ObjectDataSource1"
runat="server"
DeleteMethod="Delete"
InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="NewDataSetTableAdapters.PlansTableAdapter"

[Code].....

View 1 Replies

C# - Enable Filtering On An Objectdatasource With Filterexpression When Bound To A List <object>?

Nov 29, 2010

how to use FilterExpression with an object datasource when it is bound using a selectmethod that returns a list of entity objects?

I get the following error when I attempt it.

The data source 'testODS' only supports filtering when the SelectMethod returns a DataSet or a DataTable

View 2 Replies

ObjectDataSource Databinding: Getting Object Properties By Select Method Call - How To Access Value

Feb 22, 2010

I am using an ObjectDataSource control to call a MapInfo object. This object has two properties:

public IList Visits
public int TotalAvailable

The select method returns an IList but the TotalAvailable property is also populated. I have set the TypeName in the ObjectDataSource to the MapInfo object but because the Select method only returns the IList I don't have access to the TotalAvailable.

[code]....

Is there any way to access this value. I know it is being populated in the MapInfo object but all that gets returned from the Select method is the IList

View 2 Replies

DataSource Controls :: Make ObjectDataSource Typename Of A Singleton Business Object?

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

Forms Data Controls :: ObjectDataSource For GridView Is Not Creating Original_{0} And New Values Object?

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

Web Forms :: Accessing An Object From A Sub?

Aug 19, 2010

My form calls a sub for the onclick of the submit button. I need to access the form element with id 'form1' from this sub. I know in javascript its document.getElementById but how is this done in ASP.NET VB? And Yes I do realize I just showed off how much of a newb I am to the language but this seems to be so easy that its almost unsearchable on google.

View 6 Replies

.net - Make A DataRow Class That Implements ILiquidizable?

Dec 12, 2010

I'm trying to use Dot Liquid which is one of the coolest templating engines for c#.

Dot Liquid uses a way in order to make using templates safe. Here is the explanation page.

Here is the Explanation from it's wiki:

[code]...

So when I pass DataRow to liquid, liquid wont let me show it's content and tells me that:

'System.Data.DataRow' is invalid because it is neither a built-in type nor implements ILiquidizable

Is there any solutions to pass DataRow object that implements ILiquidizable too?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved