Monday, March 26, 2012

Listview datasource only one webservice

i use listviews to show data in the page.its datasource is bound to a webservice.But i want to use more listviews so i have to write more webservice for each one.I want to write only one webservice and call its methods.. Doesnt Listview's datasource let call webservice methods instead of webservice itself?Do i have to write the code below for each webservice class?How can i call methods in only one webservice?

[DataObjectMethod(DataObjectMethodType.Select)]

public LOGTEN.functionClass.ProductListRow[] SelectRows()

{

returnSampleDataService2.Data.ToArray();

}

Starting in the March CTP, you can have more than one select method on a data service. There is a new loadMethod property on DataSource that enables you to specify which method you want to use.

Can you give me a litte sample code part?How can i declare its methods?i think , i have to declare one default select method?

Thanks..


Sure, here's something from our unit tests:

[

DataObjectMethod(DataObjectMethodType.Select,true)]publicList<SampleRow> SelectRows() {return Data;

}

[

DataObjectMethod(DataObjectMethodType.Select)]publicList<SampleRow> SelectRowsByFirstLetters(string firstLetters) {List<SampleRow> result =newList<SampleRow>();foreach (SampleRow rowin Data) {if (row.Name.StartsWith(firstLetters)) {

result.Add(row);

}

}

return result;

}

No comments:

Post a Comment