How To Convert List<user> To List<object>
May 8, 2010i 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 Repliesi 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 RepliesI 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 ?
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.
Just wondering how to implement a user's list into website ? im using ASP.NET C#. I want to be able to:
add/delete usersadd/remove roles
I need to develop a page in my applicaiton like the image for the user lists.
I need to get the list of users under a group and need to show likw this.
[Code]....
I am getting error of in Foreach loop
[Code]....
How to resolve this situation or any other alternative to cum out of this problem.
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??
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.
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]...
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;
}
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.
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]....
How to convert list to dataset using c sharp?
View 2 RepliesI am declaring a list in my class, populating the list in page load and using the list in various methods in this class. But, I get this error at every instance where I use this list in the methods. Error: System.NullReferenceException: Object reference not set to an instance of an object.
public partial class ViewBG1 : HealthServicePage
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?
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 !
}
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 ?
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]...
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.
i have an object's list where the object has 2 attributes, id and name. I have to order the list by the name of the objects
View 6 Replieshow to convert sqldatareader to List
View 2 RepliesCreate object for list in or out of while loop?
Code:
[code]....
My question is, is there any benefit to instantiating a new userDetails object in every loop, or can this be created outside the loop and title, forename and surname just written over with every pass of the loop?
I have a dynamic sql query which contains more than one table joined. Normally I get this query to a datatable and use it. For now I want to get result of this query to a list object.
View 2 RepliesI'm try to make a little blog application in ASP.NET MVC3 with C#.I have a BlogEntry Class and Comment Class.
public class BlogEntry {
public int Id { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public List<Comment> Comments { get; set; }
[code]...
I have a list of Controls that are held in a List<Control> and I want to be able to check their type. As my list holds only Controls, doing typeof() isn't going to get me too far, I want to be able to ask if List<Control>[0] is a Checkbox, TextBox, Label, etc.How do I go about finding out what specific type of Control I have in my list?
View 7 Replies