Showing posts with label bound. Show all posts
Showing posts with label bound. Show all posts

Wednesday, March 28, 2012

ListBox - SelectedIndexChanged Problem

I have a data bound ListBox. When I click on an item it fires the SelectedIndexChanged event like it should, however, NONE of the items are marked as 'selected' in the event method. Any ideas?

Doh! Found the solution! I was rebinding the data to the listbox on postback and apparently this is what was causing the problems. I wrapped the data binding code in an IF statement that executes if IsPostBack is false.

This might be good to know for others out there.

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;

}

Saturday, March 24, 2012

ListView SelectedItem problem

I have a ListView object bound to a client-side DataTable. As I add a row to the table, I want the associated ListView item to become the selected item, as displayed using a different CSS.

I set up the listView with the selectedItemCssClass property, and as each item is clicked, it works fine. However, if I add a row to the table, the ListView re-binds correctly, but all items now appear as unselected.

This is all client-side behavior - no UpdatePanels or PageMethod calls.

1 - How do I force the record I added to become the selected item i the ListView?

2 - If I didn't want to do that, how do I ensure that the selected item remains selected when an item is added?

Much Thanks.

Although this might not work in the latest release, you should be able to set the selectedIndex or selectedItem in Javascript.

Yeah... obviously, since the Datatable went Preview some time ago. Closing this post.