Implement ObjectDataSource And IRepository?
Feb 7, 2010
I'd like to use ObjectDataSource with an instance that implements IRepository. I'd also like to be able to flexibly change the IRepository implementation through dependency injection, and switch between one that uses ORM and a fake.I currently don't see a way to do this because the ODS points to a class instead of an instance. Is there a way around this?I'm looking along the lines of having a data source class that calls a factory that creates the appropriate IRepository implemenation depending on configuration settings. However, I will have to create the implementation everytime this data source class is called, which may be expensive.
View 1 Replies
Similar Messages:
Jan 11, 2010
Not sure if this is the right forumn for this kind of question.Basically I have just started with MVC and also have done simple programming and have not used Interfaces earlier.I encountered this 3 line code used in my company application and was wondering if someone can explain me this. Thanks.
[code]...
View 3 Replies
Jul 5, 2010
i want to implement this feature in listview control which is bound to objectdatasource... and in on mouse over i have to show the data from database again. when you mouse over the linkbutton then div popup with contents...how to imlement with listview.
link for the feature is
[URL]
View 4 Replies
Apr 14, 2010
I have read many online articles showing how to implement custom paging with stored procedure and objectdatasource control. So I know the benefits of custom paging on large result sets and I know how to implement it.
In my application, I have a stored procedure which is using ROW_NUMBER and taking parameters such as startIndex, pageSize etc. I also have method in my DAL who call this stored procedure and on my page I have GridView and ObjectDataSource control and they are calling DAL methods and everything is working perfectly fine.
Now I want to implement GridView paging without ObjectDataSource control by calling the DAL methods manually. I dont want to use ObjectDataSource control because I need manual access to the DataTable my DAL methods return which I think I dont have if I use ObjectDataSource control.
how to implement paging without ObjectDataSource control
View 4 Replies
Oct 11, 2010
I have a grid view that bounded to an object data source that select data from type of student
public class student
{
int id;
[code]...
View 2 Replies
Apr 6, 2011
I tried binding a ListBox to an Object Data Source, but I can’t get the field to show up in the Data Source Configuration Wizzard for the ListBox. I got it working programatically populating the listbox using the DataReader but I’d like to be able to use the Object Data Source (Unless there are compelling reasons not to that I haven’t heard of yet.)
The code:
[code]....
View 12 Replies
Jul 28, 2010
i created an objectdatasource and bind DetailView to it.i want to set the objectdatasource.datasource to a object (for example Member class that is an Entity) it means that i want to show just one record to this with my custom method that is MemberModel.GetMemberByNationalID(string nationalID)
View 1 Replies
Aug 3, 2010
I have a gridview I want to populate with an ObjectDataSource.Problem is, when I use the wizard, I cannot find the page the ObjectDataSource belongs to, in the business object list. I can see the classes in the App_Data and App_Code, but I want to use a method in this current page´s codebehind class.
View 5 Replies
Feb 2, 2011
System.NotSupportedException was unhandled by user code
Message=The data source does not support sorting.
Source=namespace
StackTrace:
at namespace.Admin.ToolkitScriptManager1_AsyncPostBackError(Object sender, AsyncPostBackErrorEventArgs e) in C:projectMaster.cs:line 27
at System.Web.UI.ScriptManager.OnAsyncPostBackError(AsyncPostBackErrorEventArgs e)
at System.Web.UI.PageRequestManager.OnPageError(Object sender, EventArgs e)
at System.Web.UI.TemplateControl.OnError(EventArgs e)
at System.Web.UI.Page.HandleError(Exception e).......
below is my code using for simple gridview and i am only having problem with the sorting and paging is working as expected and i even define the ONSorting event but it still throws me an error: The data source does not support sorting.
namespace mynamespace
{
public class Product
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _code;
public string Code
{
get { return _code; }
set { _code = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
<asp:GridView ID="GridView1" runat="server" DataKeyNames="Id"
AutoGenerateColumns="False" OnSorting="gridview1_Sorting" DataSourceID="ObjectDataSource1" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Id" HeaderText="Id"
SortExpression="Id" ReadOnly="True" />
<asp:BoundField DataField="Code" HeaderText="Code"
SortExpression="Code" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:TemplateField HeaderText="State/Province" SortExpression="StateProvinceName".......
View 1 Replies
Sep 30, 2010
This has been covered a couple of times, without a suitable answer:[URL]
I have created a custom paging data class that is used with an ObjectDataSource. In intial tests, I found it was performing worse than my old SqlDataSource code. Whilst investigating, I found that for every page load, the ObjectDataSource is being created and binding twice.
Investigating the links above led me to believe this could be a bug (or unexplained behavior) in regards to changing my GridView's column visibility in the OnDataBound event like so:
protected void gvContacts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Pager && e.Row.Cells[0].Text != gvContacts.EmptyDataText)
{
e.Row.Cells[0].Visible = false;
if (Convert.ToInt16(lstSearchType.SelectedValue) == ADDRESS)
{
gvContacts.Columns[2].ItemStyle.Width = Unit.Percentage(30);
gvContacts.Columns[3].Visible = true;
gvContacts.Columns[3].ItemStyle.Width = Unit.Percentage(20);
}
else
{
gvContacts.Columns[2].ItemStyle.Width = Unit.Percentage(50);
gvContacts.Columns[3].Visible = false;
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["ID"] = "contact_" + e.Row.Cells[0].Text;
e.Row.Attributes["onclick"] = "javascript:selectRow($(this).attr('id').replace('contact_',''),2);";
e.Row.Attributes["ondblclick"] = "javascript:openContact($(this).attr('id').replace('contact_',''),''); selectRow($(this).attr('id').replace('contact_',''),2);";
//E-mail link
if (e.Row.Cells[4].Text != " ")
{
e.Row.Cells[4].Text = "<a href="mailto:" + e.Row.Cells[4].Text + "">" + e.Row.Cells[4].Text + "</a>";
}
//Birthday highlight
if (e.Row.Cells[6].Text != " ")
{
DateTime dt = Convert.ToDateTime(e.Row.Cells[6].Text);
DateTime now = DateTime.Now;
if (dt.Day == now.Day && dt.Month == now.Month)
{
e.Row.Cells[6].BackColor = System.Drawing.Color.FromArgb(255, 230, 160);
}
}
}
}
I use this event to customize the display of certain fields, as well as hide columns that are not pplicable during some search types. When I disable the event, the ODS stops binding twice. I can't really think of a way to get around this behavior. Has anyone else see this issue or developed a work around?
View 1 Replies
Mar 24, 2010
CheckPara is my OnDataBinding procedure SqlDataSource1 is ObjectDataSource (it's only confusing name)
Language is Nemerle, but if you know C# you can read it easy
protected virtual CheckPara(_ : object, _ : System.EventArgs) : void
{
foreach(x is Parameter in SqlDataSource1.SelectParameters)
when(x.DefaultValue=="") //Cancel binding
}
so how can I cancel binding when there is not fully configurated ObjectDataSource ? Or... how can I run binding only when I done with all parameters ?
View 2 Replies
Oct 10, 2010
I have an ObjectDataSource and I want to configure it from code behind , I want to set the InsertMethod , Selectmethod from Code Behind and set it to my Business Layer files
View 1 Replies
Jun 17, 2010
Two dropdownlist bound to two different objectdatasource.
On selection of first i get value for second dropdownlist...
Soemtime there is case when i select a value in dropdownlist 1 then i am getting no value for dropdownlist 2.
so i need to clear the items present in before in dropdownlist2.
How to do??
[Code]....
View 6 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
Mar 22, 2010
How can we use ObjectDatasource with MVP pattern in ASP.NET application?
In 3-tier architecture there is no Data Access layer,.in place of DAL, I want to consume Web Services and Request and Response is in the form of Custom objects i.e. BusinessRequest and BusinessResponse class type.
Is it possible to merge all these in one solution, MVP, 3-tier web application, No DAL, Only consuming Web Service , BAL, ObjectDataSource, GridView?
View 3 Replies
Oct 8, 2010
I'm trying to use an object Data Source as the source for a dropdown list. I have an objectDataSource that returns a data reader with two columns DepartmentID and DepartmentName. I have also tested this returning a dataset.
When I try to choose the datasource for the ddl, I can select the objectDataSource departmentdb, but I cannot select the display or value fields. I can type in the names of the fields but the page throws the error. If I click on refresh schema, not fields are displayed. I can do this easily with a SQL Data Source.
Exception has been thrown by the target of an invocation.
What am I missing? Can you use a datareader as the source for a dropdownlist?
View 3 Replies
Aug 6, 2010
I am using DetailsView attached to a ObjectDataSource to add a new record to a database. When it is complete I want to display the ID of the row that was added. I have a column in my database called ID that is set as the primary key and has Identity Specification enabled.
My Insert statement is:
{
View 3 Replies
Oct 15, 2010
If an ASP.NET web page uses an ObjectDataSource, can you configure it to use a stored procedure that uses table-value parameters?
User-defined type:
CREATE TYPE [dbo].[integer_list_tbltype] AS TABLE
(
[n] [int] NOT NULL,
PRIMARY KEY CLUSTERED
)
Stored procedure:
CREATE PROCEDURE [dbo].[GeneralReport]
@intList integer_list_tbltype READONLY
AS
BEGIN
SELECT * FROM ...
END
ASP.NET
<asp:ObjectDataSource ID="GeneralDataSource" runat="server"
SelectMethod="GetDataByRange"
TypeName="MyProject.GeneralDataSetTableAdapters.GeneralViewTableAdapter"
>
<SelectParameters>
<asp:Parameter Name="intList" />
</SelectParameters>
</asp:ObjectDataSource>
I've tried hooking into the ObjectDataSource's Selecting event like this:
[code]....
be set for UDT parameters." being thrown
View 2 Replies
Jul 28, 2010
ObjectDataSource cannot find ProductsBLL Class(with "show only data component" unchecked)?ProductsBLL.cs is located at the root of the project.
View 1 Replies
Jan 11, 2011
[Code]....
The object 'lst' is filled correctly with data. I have List<string> items in AName and DurationTime.I don't have an error, but I don't have any results.
View 16 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
Aug 15, 2010
i want to pass 3 parameters for SelectMethod and 1 parameters for SelectCountMethod of ObjectDataSource.How can i pass these?? And how ObjectDataSource can distinguish which parameters for which methods.??
View 1 Replies
Jun 2, 2010
Listview and objectdatasource binding?
[URL]
View 2 Replies
May 21, 2010
I have an issue with the object datasouce caching. Users are seeing other peoples cached records when they click next on the grid. It looks as though the caching is shared among users. Bascially when the user get to the screen they have date filters so they can further filter down the records. If another user it in at the same time and the first user hits next they get the second users filtered records.
View 3 Replies
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