How To Convert List Into Ienumerable
May 1, 2010
I am using LINQ for data connectivity and have made class which return me the result set into presentation here is the syntax:-
public List<ClsDermaInvestigation> MthdisplayInvestigation()
{
List<ClsDermaInvestigation> lstinvst = new List<ClsDermaInvestigation>();
ISingleResult<USP_Patient_Dermatology_InvestigationResult> investresult = objderma.USP_Patient_Dermatology_Investigation(PatientID, RepDate, Hb, TLC, F);
foreach(USP_Patient_Dermatology_InvestigationResult rel in investresult)
{
ClsDermaInvestigation objinvest = new ClsDermaInvestigation();
objinvest.Albumin = Convert.ToDouble(rel.Albumin);
objinvest.ALP = rel.ALP;
objinvest.ANA = rel.ANA;
objinvest.Date = rel.date;
lstinvest.add(objinvest)}return lstinvest}
This list is returning me the result.It works fine but in 1 case am using the same list to bind my Date dropdownlist.
//aspx.cs code
List<Dermatology.ClsDermaInvestigation> objlstinvest = objinvest.MthdisplayInvestigation();
//Array s = objlstinvest.to
drpDate.DataSource = s;
drpDate.DataTextField = "Repdate";
drpDate.DataValueField = "Repdate";
drpDate.DataBind();
But it throws an error that list does not conatin a property with "Repdate";. How can i bind this list with dropdownlist?? Can i convert it into some type so that i would be able to bind it??
View 2 Replies
Similar Messages:
Feb 10, 2010
Dim list As List(Of DataRow) = dt.AsEnumerable().ToList()When I compile I get the error:
'AsEnumerable' is not a member of 'System.Data.DataTable'.I added Imports system.data.datatableextensions to the file..This code works when I run it on a asp.net project But when I use the same code in Website it returns the above error..Can anyone help solve this error.
View 2 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 13, 2010
We are using WCF and ADO.NET entity framework in our ASP.NET 4.0 application. we are using Entity Framework in our WCF service to execute a storedprocedure and return the results.
[WebGet]
public List<Cs_MT> GetSearchResult(string emailId, string localTitle, string colorGrouping)
{[code]....
We are calling the WCF service from our client application and get the results as IEnumerable
IEnumerable<GetSearchResult_ByEmail_Result> SearchResult = dsContext.Execute<GetSearchResult_ByEmail_Result>(new Uri(url));
I want to loop through the records and form a new table. How to loop through it and read the values?Or How to convert IEnumerable to Datatable?
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
May 18, 2010
I've read some articles about this but for some reason they're just not doing it for me. I'd like to understand the difference between
IEnumerable<string> myList and List<string>myListToo
View 7 Replies
Sep 24, 2010
I have a string which is stored as a cookie. The string is made up of the following data:
int userId
DateTime expiryDate
A user can have a number of these, so I store them like this "userId,expiryDate$userId,expiryDate"
When I retrieve the cookie value, I then split the string and add it to a list. The list is List<OpenReviews> openReviews, which contains the two variables above. I use the following piece of code to split the string:
string[][] reviews = value.Split( '$' ).Select( f => f.Split( ',' ) ).ToArray();
As you can see it goes to an array which I then have to iterate through to add it back into my list. All of which seems extremely long winded. I believe I can use the code above to put it into an IEnumerable<IEnumerable<string>> format. The problem is I don't know how to then get it into my List<OpenReviews> I'm therefore looking at getting the split string into my OpensReviews list as efficiently as possible.
View 2 Replies
Jun 2, 2010
I would like to use the IEnumerable function Intersect() to combine a few list and get the similar integers from each list. The problem I'm faced with is that I don't know how many list I will need to compare.
Here is an example:
A{1,2,3,4}
B{1,2,3}
C{1,2}
results = A.Intersect(B).Intersect(C)
This works great, but the next time around I may have a D{1,2} next time I come across the function.
I'd like to use the Intersect method, but I'm open to new ideas as well.
View 1 Replies
May 8, 2010
i have list of user class but now i have to return it as a list of object, i try to convert it but it gives me error like. can not implicitly convert.
View 4 Replies
Aug 5, 2010
I am executing a Stored procedure from Nhibernate.Below is the sample of my code.
public IList ReportDetails()
{
session.Flush();
ISQLQuery query1 = session.CreateSQLQuery("EXEC dbo.Reports");
System.Collections.IList list = query1.List();
return list;
}
This returns me an Ilist. I want ot convert this to List of Type List<Reports>.Reports class contains all the properties which i will get from Stored Procedure.
View 1 Replies
Mar 8, 2011
I have used the Generic List , so i want to convert the List into dataset, after converting the dataset i have to export the excel in all the details,
how can i convert List to dataset , and also the Export the details.
View 3 Replies
Jul 27, 2010
Possible DuplicateNET - Convert Generic Collection to DataTable
i want to convert list datatype to datatype.
wrote the function
static DataTable ListToDataTable<T>(IEnumerable<T> list)
{
var dt = new DataTable();
foreach (var info in typeof(T).GetProperties())
{
dt.Columns.Add(new DataColumn(info.Name, info.PropertyType));
[code]...
View 2 Replies
Nov 10, 2010
I am developing a website using Visual Studio 2010, SQL server 2008 and WCF. Already i have developed DAL (Data Access Layer), for some of pages i want to use WCF services and Silverlight, I am new for WCF and i understand that all should be done in List<> for Silverlight and WCF. But all my methods in DAL will return the records in DATA SET format, So my ultimate aim is to convert the DATA SET into List. I browsed in internet and got many explanation like serialization , IEnumarable and so.... but i have 1000 of methods in my DAL, so for the each method i do not want DATA SET to LIST convertion. So i am thinking of having one common class the responsibility of comman class will be get the dataset and return the List [Convert DATA SET to LIST ] For example(Just Psedo explanation for undertanding, Ignore the Syntax error )
Public List< > DsTOLi(dsRecord)
{
// Here we will convert DATA SET to LIST
return liRecord;
}
View 3 Replies
Sep 20, 2010
I have a GenericList and i want to convert that to DataTable My code is here
[Code]....
I am getting Count in "objFinOpRegs". But i want to convert "objFinOpRegs " to DataTable.
View 2 Replies
Mar 13, 2010
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want to convert the EntityCollection of RSVP to a generic List<> of a POCO class RSVP.
So I want EntityCollection -> List. What would be the best way to go about achieving this?
So far I have this (it's missing the RSVP part)
var events = from e in _entities.Event.Include("RSVP")
select new BizObjects.Event
{
EventId = e.EventId,
Name = e.Name,
Location = e.Location,
Organizer = e.Organizer,
[Code]....
View 3 Replies
Mar 8, 2011
How to convert list to dataset using c sharp?
View 2 Replies
May 11, 2010
i have an string data array which contains data like this
5~kiran
2~ram
1~arun
6~rohan
now a method returns an value like string [] data public string [] names()
{
return data.Toarray()
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
)
List<Person> persons = new List<Person>();
string [] names =names();
now i need to copy all the data from an string array to an list<person> and finally bind to grid view
gridview.datasource= persons
how can i do it?
View 4 Replies
Mar 20, 2010
I have a list of person objects which I want to send in response to a jquery' ajax request. I want to send the list into JSON format. The list is as follows -
List<Person> PersonList = new List<Person>();
Person Atiq = new Person("Atiq Hasan Mollah", 23, "Whassap Homie");
Person Sajib = new Person("Sajib Mamud", 24, "Chol kheye ashi");
PersonList.Add(Atiq);
PersonList.Add(Sajib);
How can I convert the "PersonList" list into JSON ?
View 1 Replies
Jan 31, 2011
I stored a list<mytype> object in a viewstate. Type of list<mytype> comes from a public structure which is defined at page.
When I try to convert viewstate to a list<mytype> object it cause error.
Public struct mytype
{....}
Page_load()
{ list<mytype> obj = new list<mytype>();
viewstate["mystate"]=obj
}
My_function(){
list<mytype> tempobj = new list<mytype>();
tempobj = (list<mytype>)viewstate["mystate"];// this line cause error !
}
View 5 Replies
Feb 14, 2011
List<string> IDs = new List<string>();
XDocument doc = XDocument.Parse(xmlFile);
var query = from c in doc.Root.Elements("a").Elements("b")
select new { ID = c.Element("val").Value};
How can I convert query to List without loop foreach ?
View 2 Replies
Nov 17, 2010
I have an ASP.NET RadioButtonList on my form and I would like to convert it so that it is a JQuery Button like this.
<asp:Label ID="lblOrderType" Text="Order Type" runat="server" CssClass="label" />
<asp:RadioButtonList ID="radOrderType" runat="server" RepeatDirection="Horizontal" CssClass="radioButtonList">
<asp:ListItem value="M" Selected="True">Market</asp:ListItem> <asp:ListItem value="L">Limit</asp:ListItem>
[code]...
View 1 Replies
Mar 14, 2011
I am selecting the checked rows from Gridview. To achieve this i have written a lambda expression using dynamic keyword.
var dn = gvLoans.Rows.OfType<dynamic>().Where(s => s.FindControl("chkSelect").Checked == true).Select(s => s.FindControl("lblCD")).ToList();
I want the output of this in List. Can it be achieved by extending the query or i have to write foreach statement.
View 2 Replies
Jun 28, 2010
how to convert sqldatareader to List
View 2 Replies
Feb 24, 2010
I inherited an application written for VB.Net and am converting it over to ASP.Net, with VB as the back end. I have a data pull that adds values to a new instance of a class, then adds the item to a listbox. It worked great in the VB.Net version, but I get the following error in the Visual Studio Text Editor when I try to use the code:
Overload resolution failed because no accessible 'Add' can be called with these arguments:
'Public Sub Add(Item As System.Web.UI.WebControls.ListItem)':Value of type 'MyItem' cannot be converted to System.Web.UI.WebControls.ListItem'.
'Public Sub Add(Item as String)':Value of type 'MyItem' cannot be converted to String.
I have played around with the code quite a bit and have been researching online, but I'm just drawing a blank here.
I put the class("MyItem") in the "App_Code" folder in a file called "MyItem.vb". The class code is as follows:
[Code]....
The code I have for the sub that is supposed to add the items to the listbox is as follows:
[Code]....
View 6 Replies
Jul 28, 2010
I am trying to convert a string into a clickable hyperlink, before putting it into an array list. Here is my code and attempt, which doesnt work..
code
string stringy = gin.Value + " ";
myarray.Add(stringy);
attempt
string stringy = "<a href=http://" + gin.Value + "</a> ";
myarray.Add(stringy);
View 22 Replies