objectdatasource

How to sort using GridView and ObjectDataSource?

大城市里の小女人 提交于 2019-11-30 11:30:26
I have a GridView with an ObjectDataSource and I want to be able to sort it. Paging works correctly, however Sorting gives me an exception: The GridView gridView fired event Sorting which wasn't handled. How do I enable sorting on the server side? (i.e. gridView.EnableSortingAndPagingCallbacks must remains false) Set the gridView.AllowSorting property to true. From here the grid should allow you to sort data automatically on postback if you are using an object that implements IBindingList. However, since that is most likely not the case, you should take TheTXI's advice above and handle the

How to sort using GridView and ObjectDataSource?

痞子三分冷 提交于 2019-11-29 17:03:57
问题 I have a GridView with an ObjectDataSource and I want to be able to sort it. Paging works correctly, however Sorting gives me an exception: The GridView gridView fired event Sorting which wasn't handled. How do I enable sorting on the server side? (i.e. gridView.EnableSortingAndPagingCallbacks must remains false) 回答1: Set the gridView.AllowSorting property to true. From here the grid should allow you to sort data automatically on postback if you are using an object that implements

DataBind and Postback

落爺英雄遲暮 提交于 2019-11-29 10:37:00
This is a general how does DataBind work questions... I have a simple page with a GridView that is bound (in the aspx code) to an ObjectDataSource. I can look in the Select() function called by the ObjectDataSource to see that it is called on the initial load and on every post back. I have some logic that happens on post backs that will affect the GridView's data, and I want to call GridView.DataBind() later on in the post back, after I've made some changes. Is there a way to prevent the automatic rebinding that happens on each post back? Does this mean I can't use an ObjectDataSource for this

How do I set up ObjectDataSource select parameters at runtime

[亡魂溺海] 提交于 2019-11-29 09:08:53
I'm trying to add parameters to an objectDataSource at runtime like this: Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID); Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase); //set up object data source parameters objCustomer.SelectParameters["CustomerID"] = objCustomerParameter; objCustomer.SelectParameters["Database"] = objGPDatabaseParameter; At what point in the objectDataSource lifecycle should these parameters be added (what event)? Also, some values are coming from a master page property (which loads after the

VB.Net: How to use an Object data source in report (.rdlc)

坚强是说给别人听的谎言 提交于 2019-11-29 08:39:16
My question is similar to this one but I'm having some problems with the actual implementation. I've got a report (.rdlc) in the business layer of a 3-tier app. I've got an object in the BL ( EmployeeManager ) which has a GetEmployees(Expression as Expression(Of Func(Of Employee, Boolean))) As IQueryable(Of Employee) method. As I didn't want to try and pass a lambda in directly (at least not until I've got something working), I've created a ReportData class in the BL which wraps the GetEmployees() call and exposes the results as an IEnumerable(Of Employee) - which should be very simple. It

GridView not Rebinding Properly After Postback

ぐ巨炮叔叔 提交于 2019-11-29 04:23:30
I have a GridView that has a DataSourceID pointing to an ObjectDataSource. The ObjectDataSource points to a method that returns a LINQ IQueryable by using the TypeName, SelectMethod, and SelectCountMethod properties of the ObjectDataSource control. What happens is that the data loads properly upfront. However, on postback, if I remove the rows from the GridView and try to rebind using the explicit GridView.DataBind(), it doesn't work. I know LINQ is returning the proper rowcount and such because I've called the countmethod and it returns the proper rowcount. Here's a quick example: <asp

SqlDataSource vs ObjectDataSource

放肆的年华 提交于 2019-11-28 06:56:26
If a web page needs some data, why not just have a SQLDataSource call a stored procedure? Why use an ObjectDataSource to call a business object that then calls the stored procedure? I understand that other apps (lets say desktop apps) built on the .net framework can access the business objects, but what if the application will always be only a web app? To be more clear: When should one use an SqlDataSource or ObjectDataSource ? How does one motivate the choice? marc_s Having just a SQLDataSource is perfectly valid, if it's just a demo, a prototype, or a quick hack. It's fast, it's easy, it

How do I set up ObjectDataSource select parameters at runtime

别来无恙 提交于 2019-11-28 02:31:27
问题 I'm trying to add parameters to an objectDataSource at runtime like this: Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID); Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase); //set up object data source parameters objCustomer.SelectParameters["CustomerID"] = objCustomerParameter; objCustomer.SelectParameters["Database"] = objGPDatabaseParameter; At what point in the objectDataSource lifecycle should these parameters

Can't see or add Website Data Sources in RDLC report in ASP.NET MVC

百般思念 提交于 2019-11-27 06:05:42
问题 In the RDLC report, in Design view in Visual Studio 2008, we don't see anything in the Website Data Sources tab and the button to Add New Data Source is grayed out. Only the Refresh button is enabled, and clicking it doesn't do anything. Our business logic layer returns Lists of business objects and the business logic and business object projects are both referenced by the MVC project. This is an MVC app, so there is no App_Code folder. How do we get our business objects to appear in the

GridView bound with Properties of nested class

不问归期 提交于 2019-11-27 05:14:07
I have an object map similar to what's listed below. When I try to bind the properties of NestedClass in a GridView I get the error: "A field or property with the name 'NestedClass.Name' was not found on the selected data source." The GridView is bound to an ObjectDataSource and the ObjectDataSource is bound to a fully populated instance of BoundClass. Is there any way around this? Sample classes: public class BoundClass { public string Name { get; set; } public NestedClass NestedClass { get; set; } } public class NestedClass { public string Name { get; set; } } Evan Only immediate properties