![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
My question is I have [WebMethod] that returns an array of a object of Type OrderStatus[]. I am not using datasets, but I want to consume this from the web application and populate a repeater control. I want to be able to take this data and filter out certain rows before binding to the repeater. I just need some example code on the .net 2 web application side to see how to take this data and modify it: This is what I have today: Presentation Code: WebService src = new WebService (); Repeater1.DataSource = src.GetOrderStatusSummary(); Repeater1.DataBind(); |
#3
| |||
| |||
|
|
"Antonio (MCAD)" <AntonioMCAD (AT) discussions (DOT) microsoft.com> wrote in message news:58E19B42-CDA5-40C5-BA91-48670CE95608 (AT) microsoft (DOT) com... My question is I have [WebMethod] that returns an array of a object of Type OrderStatus[]. I am not using datasets, but I want to consume this from the web application and populate a repeater control. I want to be able to take this data and filter out certain rows before binding to the repeater. I just need some example code on the .net 2 web application side to see how to take this data and modify it: This is what I have today: Presentation Code: WebService src = new WebService (); Repeater1.DataSource = src.GetOrderStatusSummary(); Repeater1.DataBind(); You can do this in one of several ways. Here's a simple way: using (WebService src = new WebService()) // Remember that they implement IDisposable { List<OrderStatus> rawList = new List<OrderStatus>(src.GetOrderStatusSummary()); List<OrderStatus> filteredList = rawList.FindAll( delegate(OrderStatus os) { if (os.Field1 > 100 && // Your criteria here os.Field2 == "something") { return true; } else { return false; } }); Repeater1.DataSource = filteredList; Repeater1.DataBind(); } -- John Saunders [MVP] |
#4
| |||
| |||
|
|
"Antonio (MCAD)" <AntonioMCAD (AT) discussions (DOT) microsoft.com> wrote in message news:58E19B42-CDA5-40C5-BA91-48670CE95608 (AT) microsoft (DOT) com... My question is I have [WebMethod] that returns an array of a object of Type OrderStatus[]. I am not using datasets, but I want to consume this from the web application and populate a repeater control. I want to be able to take this data and filter out certain rows before binding to the repeater. I just need some example code on the .net 2 web application side to see how to take this data and modify it: This is what I have today: Presentation Code: WebService src = new WebService (); Repeater1.DataSource = src.GetOrderStatusSummary(); Repeater1.DataBind(); You can do this in one of several ways. Here's a simple way: using (WebService src = new WebService()) // Remember that they implement IDisposable { List<OrderStatus> rawList = new List<OrderStatus>(src.GetOrderStatusSummary()); List<OrderStatus> filteredList = rawList.FindAll( delegate(OrderStatus os) { if (os.Field1 > 100 && // Your criteria here os.Field2 == "something") { return true; } else { return false; } }); Repeater1.DataSource = filteredList; Repeater1.DataBind(); } -- John Saunders [MVP] |
#5
| |||
| |||
|
|
John, That worked perfectly! I have been trying to find examples of this on google with no luck. You mentioned there are several ways of doing this, do you have any links that I can read up on to learn about this area? |
#6
| |||
| |||
|
|
"Antonio (MCAD)" <AntonioMCAD (AT) discussions (DOT) microsoft.com> wrote in message news D8994A4-F5F1-49F4-9E1F-665BE39E208B (AT) microsoft (DOT) com...John, That worked perfectly! I have been trying to find examples of this on google with no luck. You mentioned there are several ways of doing this, do you have any links that I can read up on to learn about this area? Antonio, I'm glad that helped. I don't really have further links. I'd look at the features of the DataView class (http://msdn2.microsoft.com/en-us/lib...dataview.aspx). You can load your web service data into a DataSet (I do not recommend that your web service _return_ a DataSet) and then use a DataView to sort and filter it. You can then bind to the DataView. This is very flexible. You can go further than this if necessary, and create a DataSet with multiple, related tables. Some can come from your web service, some from a database, some from one or more files. You can create columns in the DataSet that are calculated from other columns, or even calculated by running totals across multiple rows. This can get as fancy as you like. The basic rule I'd use is to keep the web service interface fairly simple, using arrays instead of ArrayLists or generic lists. Then, load it into something more convenient on the client side and go wild! -- John Saunders [MVP] |
#7
| |||
| |||
|
|
John, You have been greatful in providing this information. Now i have another question which leads from the first question. My webmethod returned the object and with your help i was able to filter the list and bind it to the appropiate repeater control with no problems. Now i would like to use the rp1_ItemDataBound event to modify a field of data based on the results of the other field. So my object from previous example returns a status field and a quantity field. I want to provide a link to the status field if the quantity is greater than zero. I can not figure out how to resolve the field (WebService.OrderStatus)e.Item.DataItem).Quantity below??? |
#8
| |||
| |||
|
|
John, You have been greatful in providing this information. Now i have another question which leads from the first question. My webmethod returned the object and with your help i was able to filter the list and bind it to the appropiate repeater control with no problems. Now i would like to use the rp1_ItemDataBound event to modify a field of data based on the results of the other field. So my object from previous example returns a status field and a quantity field. I want to provide a link to the status field if the quantity is greater than zero. I can not figure out how to resolve the field (WebService.OrderStatus)e.Item.DataItem).Quantity below??? This is what I have: protected void Repeater1_ItemDataBound(Object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item) { if (((WebService.OrderStatus)e.Item.DataItem).Quantit y > 0) { //TODO: Add link to OrderStatus.Status field } } } "John Saunders [MVP]" wrote: "Antonio (MCAD)" <AntonioMCAD (AT) discussions (DOT) microsoft.com> wrote in message news D8994A4-F5F1-49F4-9E1F-665BE39E208B (AT) microsoft (DOT) com...John, That worked perfectly! I have been trying to find examples of this on google with no luck. You mentioned there are several ways of doing this, do you have any links that I can read up on to learn about this area? Antonio, I'm glad that helped. I don't really have further links. I'd look at the features of the DataView class (http://msdn2.microsoft.com/en-us/lib...dataview.aspx). You can load your web service data into a DataSet (I do not recommend that your web service _return_ a DataSet) and then use a DataView to sort and filter it. You can then bind to the DataView. This is very flexible. You can go further than this if necessary, and create a DataSet with multiple, related tables. Some can come from your web service, some from a database, some from one or more files. You can create columns in the DataSet that are calculated from other columns, or even calculated by running totals across multiple rows. This can get as fancy as you like. The basic rule I'd use is to keep the web service interface fairly simple, using arrays instead of ArrayLists or generic lists. Then, load it into something more convenient on the client side and go wild! -- John Saunders [MVP] |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |