Forms Data Controls :: How To Accept An 'object' As A Datasource (IEnumerable Or IList)
Nov 19, 2010
How do I accept an 'object' as a Datasource (IEnumerable or IList) and loop through the keys/values? I want to be able to pass anything that implements either IEnumerable or IList.
This same functionality exists on all of the .Net DataBound controls and I'm trying to figure out how it's done.
[Code]....
View 6 Replies
Similar Messages:
Feb 18, 2010
Okay, so I have a Generic IList of custom objects that I want to use as a datasource for a repeater.
[Code]....
In the WebForm inside the repeater, I place this code:
[Code]....
when I try to run it, I get the error "Unable to cast object of type 'System.Collections.Generic.List`1[MyCustomObject]' to type'MyCustomObject'. ". Which makes sense, really.
What's the best way round this? Is there any way I can get the direct cast working? I'm loath to have to create a custom list item that implements IBinding or something and bind that directly, as that'll mean a lot of legacy changes which may create further bugs. Or is there a better way?
View 3 Replies
May 4, 2012
how to populate a ilist object with data frm a sql table in code behind
View 1 Replies
Jan 2, 2010
I want to do paging the API Membership without using the datacontrols, but I get this error "Unable to cast object of type '<TakeIterator>d__3a`1[System.Char]' to type 'System.Collections.IList'." when I do this,
[code]....
View 1 Replies
Nov 9, 2010
I created one stored procedure.
/*
SP Name :sp_Par_SearchCourseFinder
Author :Mr.Ravichandran
[code]...
View 1 Replies
Aug 27, 2010
I'm trying to retrieve 3 properties from an IEnumerable object. But cant!
The 3 properties are:
serier
dage
stofnavn
This is how the code is
[Code]....
View 3 Replies
Jun 22, 2010
I am trying to write a function that can be called to run a stored procedure. I pass the stored procedure name, followed by as many parameters as I need to run the procedure. I am able to do this by using the params keyword, so my function looks something like this;
[Code]....
How can I determine what the data type of the parameter is? Maybe I need to alter the string[] part, above?
View 5 Replies
Mar 23, 2011
I am trying to bind the panel bar with the IList. I have the follwing code in my class libarry
[Code]....
I need to bind the panel bar with getmenuItems. In the above code DataReviw, Score Rep, Something else, section 2 and sample are the parent node of the panel bar and Test1,
/rRepScore/Index,
/something/something,
"Test3",
"/repScoring/Selectreps"
are the childeren of the panel bar and they are the link to another web page.
View 3 Replies
May 24, 2010
I am having trouble converting a ienumerable to a datatabe here is the code:The problem is in the following line-
ViewState("dt") = elements.CopyToDataTable()
Dim dt As New DataTable
Private Sub DisplayAuthorLastName(ByVal strLetter As String)
[code]...
View 7 Replies
Oct 21, 2010
I am having a lot of the same issue as this poster did with errors on initializing type.
I am trying to learn linq and am about ready to give up - don't get how this is easier...
I'm trying to do a simple update to product names in the product table based on the manufacturer ID
In order to do this I am looping through each record. I was initally successful with changing all names in the column but when I try to query the data, I continually run into multiple problems.
The following poster has had the same issue I have but his solution isn't working for me.
[URL]
I keep getting the same error on the opening bracket on the select statement in the SelectByManufacturerID function...
Error 1 Cannot initialize type 'DataBaseDataManagement.ProductName' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
Button that does the actual updating...
[Code]....
The function that the button calls to get the query... ERROR
[Code]....
The class located in Query.cs...
[Code]....
View 3 Replies
May 19, 2010
IEnumerable<DataRow> query = (from obj1 in objeDC.tmpPolicyRenewals.AsEnumerable()
where obj1.AgentCode == "Admin"
select new
{
obj1.Product,
obj1.PolicyNo,
obj1.Insured,
obj1.EffDate,
obj1.ExpDate,
obj1.GrossPrem,
obj1.Status
}) as IEnumerable<DataRow>;
Getting null value. whats error ?
View 2 Replies
Feb 8, 2010
Here is my code, using LinQ to get the data from database.
public IEnumerable categoryData()
{
db = new DBModelDataContext();
var cat = from c in db.Categories
select new { c.categoryname,c.categoryid };
return cat;
}
trying to get the values (categoryname and categoryid) into textfiled and valuefield of dropdown list.
dt = new clsData();
ddlCategory.DataSource = dt.categoryData();
what is the code that i need to write to assign the categoryname to textfield and categoryid to valuefield. I mean how to loop through the values coming from the above function.
ddlCategory.DataBind();
View 2 Replies
Jul 22, 2010
I want to delete the rows present in the DataTable by using LINQ (with out looping)
The deleted rows will be come from a LINQ as below
IEnumerable<DataRow> MobileQuery = (from d in dtBillDetail.AsEnumerable()
where (String.Compare(d.Field<string>("Destination"), "MOBILE", StringComparison.InvariantCultureIgnoreCase) == 0) select d );
The DataRows present in the "MobileQuery" should be deleted in the DataTable "dtBillDetail"
View 1 Replies
Dec 17, 2010
I have an IEnumerable object (IEnumerable<Class>) and I would like to retrieve a specified line from the object. So if I'm on page two I would like to select row two from the IEnumerable object and then pass it on to another class etc. I'm a bit stuck at the moment, any ideas?
View 3 Replies
Sep 21, 2010
If I ran my sproc from query analyzer, I get the correct results(data is filtered by datetime), i.e:
exec Uds.Dashboard_GetJobs '9/20/2010 11:01:23 PM'
However, if I ran it from the Asp.Net page, (ALL records are showed). Looking at the SQL Profiler I see the following call:
exec sp_executesql N'exec Uds.Dashboard_GetJobs',N'@date nvarchar(21)',@date=N'9/20/2010 11:01:23 PM'
Running both statements above in the query analyzer it WILL return me different results. Why? Someone mentioned that it looks like I don't have correct data type specified for SQLParameter in .Net application. I was asked to create something like:
cmd.Parameters.Add("@Date",SqlDbType.DateTime).Value =
Well, my code in the asp.net is in this form:
<asp:SqlDataSource ID="sourceRealtimeLogging" runat="server"
ConnectionString="<%$ ConnectionStrings:UctConnectionString %>"
SelectCommand="exec Uds.Dashboard_GetJobs">
<SelectParameters>
<asp:ControlParameter ControlID="UpdatedTimeUTC" Name="date" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
So I guess I am passing a string to SQL, not a datetime type. How do I fix this? Not even sure if this is the cause of my issue but worth a try.
View 3 Replies
Feb 18, 2010
i am a new bee in SQL Server 2005. I have a stored procedure that accept two parameter , variable @ColumnName as column name and @SearchText as search text.
My stored procedure is written as below:
[Code]....
but the error i get is "The 'usp_GetPlantTest' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead."
View 4 Replies
Nov 20, 2010
question is same as in thread, but also i would like to see example of this.
View 1 Replies
Mar 14, 2010
I have a dataset that has two datatables. In the first datatable I have EmpNo,EmpName and EmpAddress. In the second datatable I have Empno,EmpJoindate, EmpSalary. I want a result where I should show EmpName as the label and his/her details in the gridview. I populate a datalist with the first table, and have EmpNo as the datakeys. Then I populate the gridview inside the datatable which has EmpNo,EmpJoinDate and EmpAddress. My code is
[Code]....
My Design is
<asp:DataList ID="Datalist1" runat="server" DataKeyField="EmpNo">
<ItemTemplate>
<asp:GridView ID="Gridview1" runat="server">
</asp:GridView>
</ItemTemplate>
</asp:DataList>
I do not get results in the gridview, instead have errors. I tried then placing the bound field
<asp:GridView ID="Gridview1" AutoGenerateColumns="true" runat="server">
<Columns>
<asp:BoundField DataField="EmpNo" />
</Columns>
It throwed an error stating / A field or property with the name 'EmpNo' was not found on the selected data source.
View 3 Replies
Feb 15, 2010
I've a listview where in am using object datasource to bind the data.I've few questions with the object datasource. Will object datasource load the page twice?Also is there any way to stop listview autobind with object datasource i.e i want the listview binding to be controlled by code behind. Now i see i cant control the listview binding on page load.. object datasource is taking care of that?The problem i'm facing is that am getting my control coming to page load twice.
View 3 Replies
Aug 9, 2010
This is the first time I have been working on databases and I am trying to insert data using an object datasource but no data is being inserted and no exception is thrown. I'm not sure where I am going to wrong. I am putting user data into session variables and inserting the session variables into the dataacess class layer and have a try and exception but nothing being thrown. Any help would be really appreciated because I don't know even where to start looking with this or how I can get the error to be thrown. Please see some of my code below to give an idea of what I am doing
Object Access Class
public void InsertCarPolicyHolder(PolicyHolderClass ph, CarInsuranceOptions options)
{
[code]...
View 2 Replies
Dec 8, 2010
I have an object datasource which is using Business object as a myconnection
The method i have defined under myconnection is
Publicstatic
DataTable getfn(String dtype,
String did,
String dprefix,
String dname)
{
datable table = new datatable(); then declared stored proceedure and defined parameters and assighned values
In the stored proceedure it has a query like select column1,coloumn2,coloumn3 As Call from table where
I need to take data from Call and display it to the gridview through object datasource .
View 1 Replies
Feb 1, 2010
I am using a list of objects as a datasource and passing the object into a user control. I use the code outlined below
[code]...
When I try to access the object this way, it's null.
Funny thing, I can access the user control and all the control data in the user control, but the object (both in the gridview and passed to the user control) are null.
View 1 Replies
Oct 6, 2010
I have a need to add a new report to my page, the differnent parts of the page are all using a objectdatasource to populate the data. The new report because of all the data being returned i have started to use a repeater and a table in the ItemTemplate. Just binding the objectdatasource to the repeater works fine, but returns all the records and causes the page to be very long. I found this link for adding paging to repeater, but its setup different than what i have
[URL]
Is there any way to use what i have already and add paging to the repeater?
[Code]....
View 3 Replies
May 3, 2010
Traditionally with an Object Data Source, the wired up class will have its public properties available for binding (i.e. Gridview columns, etc.) which works well. But what if one of my wired up business objects has a property that is an object itself; can I drill down to a property on that object property and still use it?
So in additiona to the traditional:MyBusniessObject.OrderID...I want to use:MyBusniessObject.Customer.NameID
Your 1st response might be to just wire up the 'Customer' class, but I need properties both on 'MyBusinessObject'and 'Customer'. I do not think this can be done, as the ODS will not display properties on an object instance property. I have tried manually typing in the drilled down value as well, but that wasn't a success either.
View 4 Replies
May 20, 2010
I want to display images, which i stored in the MSSQL 2008 with the type of varbinary, in a gridview.
I am using N-Tier to support my web application, i can get the image's value which is in binary type, but i do not know how to display it via a gridview.
View 3 Replies