objectdatasource

asp.net how can ObjectDataSource access System.Web.UI.Page objects

心不动则不痛 提交于 2019-12-05 21:52:10
I use ObjectDataSource as below. <asp:ObjectDataSource ID="Item" runat="server" SelectMethod="Grid_DataBind" TypeName="XXX.XXX.XXX" DataObjectTypeName="Controller.Items" UpdateMethod="UpdateRow_Grid" InsertMethod="InsertRow_Grid"> When InsertMethod fire, everything work fine but ... public IList<Items> InsertRow_Grid(Items item) { item.ID = System.Guid.NewGuid().ToString(); bool contains = GridSource.AsEnumerable() .Any(row => item.JobID == row.JobID); if (!contains) { GridSource.Add(item); } else { lblMsg.Text= "This record has already exists."; } return GridSource; } It doesn't know my label

ASP.NET 2.0: Specifying an instance of an object for an ObjectDataSource

被刻印的时光 ゝ 提交于 2019-12-05 19:43:18
I'm using an ObjectDataSource to bind data to a GridView; it works fine except that it always creates a new object to use as a data source. I can do all the setup just fine but I cannot use an instance of an existing object to specify as the "data source" for it. Is it possible to do this? If so, how? If it's not possible, why? EDIT: Here's the gist of what's going on (object types changed): On the first page you are editting the attributes for a dog. One of the attributes is "has puppies" and if it's true, the next page you specify the names of those puppies. What's happening in my case is

Objectdatasource and Gridview : Sorting, paging, filtering

不想你离开。 提交于 2019-12-05 18:02:12
Im using entity framework 1.0 and trying to feed out a Gridview with a objectdatasource that have access to my facade. The problem is, that it seems to be particulary difficult and haven't seen anything that realy do what i want it to do on the internet. For those who know, a gridview feeded with an objectdatasource, it can't sort automaticaly then you must do it manually. It's not that bad. Where it becomes a nightmare, its when we add paging and filter settings to a gridview's datasource. After many hours searching on the internet, i'm asking you, guys, if anyone knows a link that can

Using ObjectDataSource and DataObjectTypeName, How Do You Handle Delete Methods With Just An Id Parameter?

回眸只為那壹抹淺笑 提交于 2019-12-05 15:19:27
If I have an ObjectDataSource setup like: <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="Employee" InsertMethod="Insert" UpdateMethod="Update" DeleteMethod="Select" TypeName="EmployeeDB"> </asp:ObjectDataSource> and a data/business object with methods like: public class EmployeeDB { public void Insert(Employee emp) public int Update(Employee emp) public bool Delete(int id) } How do I get the objectdatasource to use the Delete method with the parameter that is not an Employee object? If this is not possible, what is the recommended alternative architecture? Edit

How to get row count of ObjectDataSource

天涯浪子 提交于 2019-12-05 03:06:30
Hello you all How can i get row count of ObjectDataSouce ? I use ObjectDataSource and DataList . I want show some thing to the user for example in a label when there are certain row returned by ObjectDataSource . One of situation is when there is no record . Thank you . I was looking for the same answer... Another solution I ended up using is the following: This is found on a .vb file behind an .aspx page. It handles the "selected" event of the datasource. Protected Sub ObjectDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs)

Optimize Pagination & Sorting with ObjectDataSource having EnableCaching = true

浪尽此生 提交于 2019-12-04 04:43:38
问题 I'm using an ODS(ObjectDataSource) backed-up with a Linq-To-SQL class to populate Gridview on my page. Considering the performance - I've disabled the Viewstate of the Gridview and enabled caching in the ODS. Apart from this, I've also optimized the Search method in the Linq-to-SQL class to use the .skip & .take methods to fetch only a 'pageful' of records. Now, the problem is that due to caching the ODS is unable to 'sort' the record set on its own. As detailed on this thread: GridView

SPGridView, data and correct method of ensuring data is safe

萝らか妹 提交于 2019-12-03 17:35:44
I am using an SPGridView to present some data, and have enabled the filtering ability which works very well. Until you choose a particular item in the data to filter on... The data item in question has an apostrophe in the string( e.g. "this is richards' string"), which causes the post-filter-application page load to die with the error: Syntax error: Missing operand after 's' operator. Obviously the data is not automatically made safe... The data is in a datatable, and the SPGridView is fed using an objectdatasource using the datatable. Whats the best, or correct, method to ensure the data is

ObjectDataSource Gridview Insert Fails W/ Empty Values Dictionary

强颜欢笑 提交于 2019-12-03 16:43:19
I have a gridview to which I have created an Insert Template in the footer row. I have an ObjectDataSource which is bound to a business object. I have an OnInserting event handler which never gets fired. The program encounters an error once I call .Insert on the ObjectDataSource. The error I receive is that there are no values and that I should check to make sure the values dictionary is not empty. I do not see a way to insert with a dictionary as a parameter. I have seen mention of grabbing the ObjectDataSourceView and using it's Insert method but I do not see any mention of how to do that

GridView's UpdateMethod not firing

﹥>﹥吖頭↗ 提交于 2019-12-02 09:09:18
I've got a GridView that I bind to a ObjectDataSource programmatically, like: ObjectDataSource risks = new ObjectDataSource("Risks", "RetrieveProjectRisk"); risks.TypeName = "Promanto.ProjectRisks"; risks.DataObjectTypeName = "Promanto.ProjectRisk"; risks.SelectMethod = "RetrieveProjectRisk"; risks.DeleteMethod = "DeleteProjectRisk"; risks.InsertMethod = "AddProjectRisk"; risks.UpdateMethod = "UpdateProjectRisk"; risks.SelectParameters.Add("WhereClause", TypeCode.String, "ProjectID ='PR0002'"); RisksGrid.DataSource = risks; RisksGrid.DataBind(); But when I click the edit button and I then

Can you get a DataTable from an ObjectDataSource?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 01:15:14
If I have an ObjectDataSource defined at design time, can I get a DataTable from that ObjectDataSource at runtime? I have a method that returns a DataTable that I am using for the Select method property of the ObjectDataSource. I don't really understand your question... are you asking if the object you define in the ObjectDataSource can return a DataTable in the configured select method? Yes, I do it all the time. You can also examine the returned DataTable in the OnSelected event (it is the ReturnValue property of the event object). Yes, but you need to pay attention to when that item has