.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Navigate through a generic list using a webservice

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
 
Hi I have a problem where I would have a dataset coming to me and I would break into 5 new generic LIST<>. Now the user needs to see one record at a time and navigate through the list Fields like               From date : Text box with calendar                To Date : Text box with calendar               Manager Reporting To : Drop down list                Buttons on Move Back  and move Forward Now I would have 4 such similar lists which I have to pick up from the audit table. When the user clicks on move back and move forward buttons he should be able to navigate through records in my list that I have fetched in the beginning . I can store it in a session or viewstate till it gets updated again. How do I achieve this. Can I also a gridview instead of textboxes. What should be the simplest way to achieve this. Thanks!      


View Complete Post


More Related Resource Links

Generic list with WebService throws 'Two Mappings for []' exception

  

Please consider below libraries:

ClassLibrary.dll (Smart Device Class Library project)

 public class B
    {
        public string test;
    }

 public class C
    {
        public List<B> tempList = new List<B>();
    }

WebServie (.NET 2.0)

Contains reference of ClassLibrary.dll
public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public List<B> ListOfB( string str)
        {        
            B obj = new B();           
            obj.test = str;

            List<B> list = new List<B>();
            list.Add(obj);
            re

Format Generic List Bound to Gridview

  

I have a generic list of a custom type. The custom type has a string and double.

I'm binding the list to a gridview and it outputs everything fine.

I'm trying to format the double column into a currency format. It is in a template field as I'm calculating a running total. I pass the value to a function that returns a double and adds the current value to a running total which I will show in the footer.

The format is not changing to currency as expected when using String.Format("{0:c}", GetTotal(Convert.ToDouble(Eval("Amount"))))


Any ideas on what might be going on and how to fix this?

Thanks!


How to Cache System.Collection.Generic.List object

  

I need to cache System.Collection.Generic.List object with expiration time

var Root = from feed in feedhotel.Descendants(ota + "HotelContent")
                           where (feed.Attribute("HotelCode") != null)
                           select new xmlhotel()
                           {

....

....

    };

return Root.ToList();

Is it possible to cache Root.ToList() for some time....





How to navigate through a list stored in session

  
Hi I have a problem where I would have a dataset that I would break into 5 new generic LIST<>. Now the user needs to see one record at a time and navigate through the list Fields like               From date : Text box with calendar                To Date : Text box with calendar               Manager Reporting To : Drop down list                Buttons on Move Back  and move Forward Now I would have 4 such similar lists which I have to pick up from the audit table. When the user clicks on move back and move forward buttons he should be able to navigate through records in my list that I have fetched in the beginning . I can store it in a session or viewstate till it gets updated again. How do I achieve this. Should I be writing  a webmethod to go back and pick up the next record agian and display Can I also a gridview instead of textboxes. What should be the simplest way to achieve this. Thanks!      

text box binding with Generic list

  
Hi, I am working in asp.net 3.5 page, where I want to bind a textbox with generic list data. And I have Previous & next button. Which will show the record in textbox. I don't want to go in db again and again.  Is it possible.??? 

Weird casting error (storing Generic list in Session)

  

Am trying to store a generic list in Session to act as a simple shopping cart. Am getting a weird casting error when I try and retrieve it from Session.

A critical error has occurred.
[A]System.Collections.Generic.List`1[MyCartItem] cannot be cast to [B]System.Collections.Generic.List`1[MyCartItem].
Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.
Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.


I have a class variable defined:

List<MyCartItem> _cart;

In the Load event I have:

_cart = (Session["MyCart"] != null) ? (List<MyCartItem>)Session["MyCart"] : new List<MyCartItem>();



Generic List to DataTable

  

Hi,

I have a GenericList and i want to convert that to DataTable

My code is here


Dim queryF = From FinOpeningRegisterBranch In db1.FinOpeningRegisterBranches Where FinOpeningRegisterBranch.YearID = AccountLoginYearID.ToString And FinOpeningRegisterBranch.BranchCode = getBranchCode(txtBranch.Text, Me.Context) 
objFinOpRegs = CType(queryF.ToList(), List(Of FinOpeningRegisterBranch))


I am getting Count in "objFinOpRegs". But i want to convert "objFinOpRegs " to DataTable.

Thanks



help passing generic list to method

  

I have several lists in one class. When I add an class/object  to a list I want to be able to check if it doesn't exist already in the list. I've done this using a method that checks the particular list individually but would require a method for each list eg


private bool checkShipList (List<Ship> ship, Ship newship)
{

//check list code

}


How can I make it so I use only one method for all lists and can pass the new object to it to check. I used List<T> in the method but can't get it right with the second parameter. Thanks for any help.




using share point list webservice

  

 

 

HI all,

i am new to sharepoint development. i'm currently try to access the sharepoint server my local machine and having access only to a inner document library.i need to get all data inside that document library. i'm trying to use list.asmx service to retrive all items inside that document library.

but i'm getting error ''401 Unauthorized".

my sharepoint url is like http://mysite.com/Sites/MainCollection/abc/asd

i'm having acces only to asd document library.i need all items (folders and files) inside this document library.

service i'm using is http://mysite.com/_vti_bin/Lists.asmx.

i'm able to add the service to my local project and view all the methods inside the list service but getting error when try to access it.

could someone help me please.

 

thanks,

Arun

Xml Serialization: choose tag name for class instances in a generic ObservableCollection / List

  

Hi,

I've creating a class called Graphics, deriving from a generic ObservableCollection where T is a custom class called Graphic :

public class Graphics : ObservableCollection<Graphic>
{
public Graphics()
{
}
}

Another class has a Graphics field. When I serialize to XML this class, this works fine :

<MyOtherClassInstance>
 <Graphics>
  <Graphic id="1">
  <Graphic id="2">
  <Graphic id="3">
 </Graphics>
</MyOtherClassInstance>

But I would like to have the following:

<MyOtherClassInstance>
 <Gs>
  <Gr id="1">
  <Gr id="2">
  <Gr id="3">
 </Gs>
</MyOtherClassInstance>

How can I process, I can't find a solution.

Please help.

Thanks


Xml Serialization: change tag name of class instances in a generic ObservableCollection / List

  

Hi,

I've creating a class called Graphics, deriving from a generic ObservableCollection where T is a custom class called Graphic :

public class Graphics : ObservableCollection<Graphic>
{
public Graphics()
{
}
}

Another class has a Graphics field. When I serialize to XML this class, this works fine :

<MyOtherClassInstance>
 <Graphics>
  <Graphic id="1">
  <Graphic id="2">
  <Graphic id="3">
 </Graphics>
</MyOtherClassInstance>

But I would like to have the following:

<MyOtherClassInstance>
 <Gs>
  <Gr id="1">
  <Gr id="2">
  <Gr id="3">
 </Gs>
</MyOtherClassInstance>

How can I process, I can't find a solution.

Please help.

Thanks


ListData.svc REST API can't navigate relationship to lookup list in parent site

  

I have created a list in the root web that contains common information used by multiple sites throughout the site collection.  I have also created a site column that is a lookup column which pulls from that list.  This way, I can add the site column to any list in any sub site in the site collection. 

I have a list in a sub site in the same site collection that I have added the root web site column to and, from the UI perspective, everything works great.  I can add a list item to the sub site list and select an item from the root web list for that column. 

However, if I generate a strongly typed data context and associated classes using a Visual Studio service reference to ListData.svc (or if I just play around with the REST XML in the browser), the class property which represents the lookup column in the sub site list only contains the ID of the lookup item, not a reference to an instance of the item. 

I understand that the experience getting list information from a different site is usually less than optimal but are there any workarounds to get a reference to that lookup list item via the REST API?


Update value in generic list

  

I have a list of items containing my own custom class:


List<MyClass> myList = new List<MyClass>();

MyClass consists of:

int seq;

string name;

string cssClass;


The list is populated via a linq query.

I check if the name is equal to the current page name and if so update the value cssClass.  This will only happen with 1 out of approx 10 records.

I thought about iterating through the list with a for each, but can't update myList.cssClass as it is read only.

I therefore have 2 questions:  1) Is a foreach the right way of tackling this?; 2) How would I go about updating the list value?


Thanks in advance.


John




Creating new List Item with Lookup, Owner and DateTime fields WebService

  

Hi,

I've created a function that creates a List Item, given a bunch of values (Using the WebService). This works fine when I try to populate plain text fiels. But in the list item there are a few picklists and an owner field. When I try to populate these, I get no error but the new record is not created:

      //batch.SetAttribute("OnError", "Continue");
      batch.SetAttribute("ListVersion", "1");
      batch.SetAttribute("ViewName", "");

      batch.InnerXml =
        "<Method ID='1' Cmd='New'>" +
        " <Field Name='ID'>New</Field>" +
        " <Field Name='Title'>" + title + "</Field>" +
        " <Field Name='Owner'>" + owner + "</Field>" +
        " <Field Name='Status'

Generic list of custom class returns data in WCF service layer, but loses them in Presentation Layer

  

I'm reading this excellent article by John Papa in MSDN Data Points - http://msdn.microsoft.com/en-us/magazine/cc700340.aspx

This single article alone sheds great deal of light on EF, WCF, WPF, MVP architecture, Layered Architecture with these technologies and so much more.

I'm trying to experiment with the code that comes with the article as is.

When executing the application, the service layer returns a Generic List with three Customer objects to the presentation layer. However, in presentation layer, the Generic list arrives with zero objects in the list. In the context of this application, I provide 'd' as a search criteria and hit the search button; while stepping through, I can see it returns 3 rows from the database.

With my limited experience in WCF, I am unable to figure out why it is so. This article was written  for 3.5 SP1 Beta 1. Could something changed in the general release that is causing this?


-Perennial Newbie-

Confusion about web service return types (classes, generic list)?

  
Hi,

I have confusion about web service return types? Can a webservice return a genelist? ex: List(Of Employees)

I have searched threads in this forums but got confused, some say 'yes' some say 'no'.

If I mark the class as Serizable will that be enough to return a generic list?

thanks

Webservice Return as List Need Help to set result as List

  

Hi all,

I have webservice which return list of class.

@WebMethod()
    public List<Myclass> MyMethod(String ID)

{

//some operetions is done

}


I am calling this service and I want to get result as list.

its accessable myclass (public) ad myMethod Public

I tried

List<myservice.Myclass> myserv=new List<myservice.Myclass>();

I want to result to bing on above variable.

myservice.NewWebServiceService newme = new dene.NewWebServiceService();

myserv=newme.MyMethod("Test");

I gives an error such as

Error    1    Cannot implicitly convert type 'WindowsApplication1.myservice.Myclass[]' to 'System.Collections.Generic.List<WindowsApplication1.myservice.Myclass>'    C:\Documents and Settings\Mikail\Belgelerim\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs    24    20    WindowsApplication1


Thanks for any reply.



Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend