Showing posts with label item. Show all posts
Showing posts with label item. 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

ListSearch with ~15,000 items under dropdownlist

I have a dropdownlist with around 15,000 items, which can be quite irritating for a user to select the right item.

So, I put in ListSearch to facilitate the selection process, but now I'm noticing that there's about 5 second delay from the moment I start typing the first few characters of the item and the time I actually see the typed characters below my dropdownlist. And 5 seconds is way too long of a delay!!

When I tried the same ListSearch on a dropdownlist with a fewer number of items (say...about 100), then it worked instantaneously.

Has anyone seen similar problem? And how can I make ListSearch work faster?


Thanks.


Hi,

The ListSearch delays any processing until the first time the user starts typing. This is by design (on a number of our components) because if you put a few dozen components in a repeater you don't want them to all do their processing at once when the page loads. I'm a little skeptical that you really want to put 15,000 items in a drop down (instead of providing a search/results selection UI with something like modal popup), but you could probably tweak the ListSearch beahvior pretty easily to start processing the items in its initialize function.

Thanks,
Ted


I agree with you. Putting more than 15,000 items under a dropdownlist is an overkill, but I'm currently migrating our old ACCESS application to ASP 2.0 and it is required to stay with the same dropdown control. Apparently, ACCESS's version of dropdownlist can handle 15,000 items and has the capability of search incrementally. So, I'm kinda stuck with a dropdownlist here. :-(

I guess the users don't want to go through few more clicks with the search/results selection page.


With that aside, what did you mean by "tweaking ListSearch"?? Would you be able to show me an example or direct me to some website where I can look into?

Thanks for your help.

-Brian


Hi,

Get the full source version of the Toolkit and look at the AjaxControlToolkit\ListSearch\ListSearchBehavior.js file. You can experiment with moving the _isSorted check (line 242) from _onKeyDown to initialize (remember to rebuild when you change one of the scripts as they're embedded resources). I think this would help fix the delay you're seeing the first time a user accesses the list.

Thanks,
Ted


Thank You!


I've written a blog post explaining how you can alter the ListSearch Extender to speed up the initialization by giving it a hint as to whether the target list is sorted or not. It is the determination of whether thie list is sorted or not that takes a long time.

http://damianblog.com/2007/06/19/speeding-up-listsearchextender/

If there is enough interest, I'd be happy to add the changes to the control toolkit.


Thank you for this. I will definitely take a look at this and hopefully I'll get the ListSearch Extender to work faster.

-Brian

ListSearch doesnt work with Dropdownlist AutoPostBack

ListSearch works fine finding a specific item on a dropdownlist, but doesn't fire an AutoPostBack event when I tab over (or tab out).

I found this 3rd party add-on control that does exactly what I'm looking for, but was wondering if there's a similar dropdownlist available from Microsoft.


Check out the "Contact Information" section.

http://samples.asplib.net/AspLibSamples/ComboBox.aspx


Also, any easy way to display the prompt text "left" of the dropdownlist. Apparently, there are only two options: top or bottom.

Thanks.


Hi,

You can use the following code to force a postback when the dropdownlist losts focus.


string script = ClientScript.GetPostBackEventReference(DropDownList1, "");
DropDownList1.Attributes.Add("onblur", script);

Hope this helps.


That did the trick! Thanks!!

ListSearchExtender caused 2 postbacks instead of one

When I change selected item in DropDownList, then begins asynchronous postback and some UpdatePanels are reloading. I put one break point in the Page_load event. This break point activated once for each time when I changed selection in the DropDownList. So everything was ok.

 <asp:DropDownList ID="ddl_otdel" runat="server" AutoPostBack="True" DataTextField="otdel_name" DataValueField="id" OnDataBound="ddl_otdel_DataBound" OnSelectedIndexChanged="ddl_otdel_SelectedIndexChanged" />  <%-- <ajax:ListSearchExtender ID="listSearch_ddl_otdel" runat="server" TargetControlID="ddl_otdel" PromptCssClass="ListSearchExtenderPrompt" PromptText="Введите начало строки..." > </ajax:ListSearchExtender> --%>
After that I decided to use ListSearchExtender with my DropDownList. Since that moment my break point (in Page_load) began to activate twice for each time when I changed selection in the DropDownList. When I commented ListSearchExtender then everything became ok. Why there are 2 asynchronous postback instead of one?

May be my question isn't correct. Maybe I don't understand many things. But there is a problem that in some conditions ObjectDataSource executes SelectMethod when it's not necessary and page is going through server-cycle twice during one postback.

ListSearchExtender and TAB

Hi

I am beginning to use the ListSearchExtender and it works but only if I press Enter or click with the mouse on selected item; when I the press the TAB and focus leaves the ListSearchExtender and goes to next control the ListSearchExtender returns to first item... must of the users uses the TAB to go to next field/control. How can the ListSearchExtender keep its selected value?

Any solutions?

Thanks!

/Staffan

Smile to make the question a litte bit better; TAB functions well when I am NOT dropping down the dropdown i e it keeps selected value, but if I dropdown the dropdown and then types some valid characters and then press TAB it returns to first item?

Kind Regards

STaffan


Hi,

The item is remained selected when I press tab according to my test.

Please try this sample:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.DataSource = this.GetWordListText(); DropDownList1.DataBind(); } //string script = ClientScript.GetPostBackEventReference(DropDownList1, ""); //DropDownList1.Attributes.Add("onblur", script); //DropDownList1.Attributes.Add("onchange", script); //Response.Write(DropDownList1.SelectedValue); } public string[] GetWordListText() { string[] tempWordListText = new string[] { "Alfa", "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Xray", "Yankee", "Zulu", "Zero", "Nadazero", "One", "Unaone", "Two", "Bissotwo", "Three", "Terrathree", "Four", "Kartefour", "Five", "Pantafive", "Six", "Soxisix", "Seven", "Setteseven", "Eight", "Oktoeight", "Nine", "Novenine" }; Array.Sort(tempWordListText); return tempWordListText; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> <ajaxToolkit:ListSearchExtender PromptPosition="Top" ID="ListSearchExtender1" runat="server" TargetControlID="DropDownList1"> </ajaxToolkit:ListSearchExtender> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </form></body></html>

Hope this helps. If it doesn't, please provide a simple page without relying on any specific DataBase or class.


Hi!

When I am using your code and:

1. Click the downarrow to "downdrop"
2. When I see the beginning of the list and I am typing for example charli and then direct press TAB on my keyboard the dropdown selects Alfa.

?

Best Regards!

Staffan

ListSearchExtender Question

My users have a listbox that I am using the listsearchextender to help them, however if a value is not found in the list what ever the last item similer

is left in the list box.

is there a way to say change the color to red if they start typing some thing not found in the list?

Hi,

This isn't a build-in feature. If you really need this, you may have to modify its source code.

Please investigate the _searchForTypedText method in ListSearchBehavior.js file and add necessary codes.

Saturday, March 24, 2012

listView item styling

I'm trying to get a listView control to display a certain style from a cssClass on the clicked item (which I have working) and then when a different item is clicked, the style is added to the new item and removed from the old item. Only one item in the listView can be selected (styled) at one time.

<listView targetElement="names" itemTemplateParentElementId="itemTemplateParent">

<bindings>

<binding dataContext="dataSource" dataPath="data" property="data" />

<binding dataContext="dataSource" dataPath="isReady" property="enabled" />

</bindings>

<layoutTemplate>

<template layoutElement="template" />

</layoutTemplate>
<itemTemplate>

<template layoutElement="itemTemplate">

<control targetElement="itemTemplate">

<behaviors>

<hoverBehavior>

<hover>

<invokeMethod target="itemTemplate" method="addCssClass">

<parameters className="rowHover" />

</invokeMethod>

</hover>

<unhover>

<invokeMethod target="itemTemplate" method="removeCssClass">

<parameters className="rowHover" />

</invokeMethod>

</unhover>

</hoverBehavior>

<clickBehavior>

<click>

<invokeMethod target="itemTemplate" method="addCssClass">

<parameters className="rowClick" />

</invokeMethod>

</click>

</clickBehavior>

</behaviors>

</control>

<label targetElement="nameLabel">

<bindings>

<binding dataPath="Name" property="text" />

</bindings>

</label>

</template>

</itemTemplate>

<emptyTemplate>

<template layoutElement="emptyTemplate" />

</emptyTemplate>

</listView>

I don't believe you can do this declaratively in a clean way. Toachieve this, you should probably extend the ListView control andimplement the concept of selections inside the listview itself. Thatway the listview can keep track of a selected item, so the user of thatlistview doesn't have to. If you want to give this a try yourself,you'll probably want to handle the click event of each item instance,and add a few properties/events like "selectedCssClass", "selectedItem"and "selectedIndexChanged".

We've already implemented selection for listView, it should be available in one of the next builds. We don't have selectedCssClass yet, but it looks like a good idea. I'll open a bug to track it.

ListView Performance

Dear community:

I have started a new feedback item on the MSDN Product Feedback center about the poor performance of ListView databinding in ATLAS.

Please view the details here:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=176826

I encourage you to view the feedback and comment and share your experiences. I believe this to be a major problem with ListView and, indeed, the way databinding happens in ATLAS on the client side (due to the MarkupParser.parse() method being called for each data item).

If you do not experience these problems, then please comment on that feedback item and let Microsoft (and me!) know in case this might be a special-case problem only for some browsers/installations.

I appreciate your time in this matter and I hope this will make ATLAS and even better product!!

Hi,

I completely agree with you. ListView is too slow to load.
Displaying 50 records takes foreverSad.

I realized this problem when I started the development way back in April 2006. But continued using Atlas in the hope that performance will improve in the coming CTPs. Now the code is in production and the users have been complaining that Listview takes lot of resources (CPU: 100%) and lot of time to display.

I haven't tried using the AJAX RC because of the breaking changes involved. The other option for me is to use the Gridview server control.
Either way its rework for me.

Hoping that Microsoft Team will release a fix for the CTP version.

Regards,
Tim


I'm very new to the ListView, just a few experiments so far but I did notice (for my 10 records) that, strangely, athough I was using ListView to render a table (which will usually not display until fully loaded) the table would appear incrementally, the table headers, then with a couple of rows, then a couple more, finally the entire 10 rows.

I was taken aback that the data was not converted to a "rendering object" (ie an entire table) THEN rendered to screen, it seemed to do a bit, render, do a bit more, render etc etc.

Usually I've found Databinding to always be faster than manually looping through records and adding the results to a list. In THIS case, I suspect the opposite would be true, the only thing the databinding is giving you is the ability to define Template objects and databind in one line of code without iterating.


hello.

though i haven't looked at it for some time, i think that the erndering is done from x to x rows which are then inserted on the screen...


Would be consistent with my observations, but seems like a strange way to do it. For example, if you were rendering a 3D game image, you wouldn't render X polygons, swap the display buffers, then take the previous rendering, add a X more polys, swap the buffers agaim, until finally you had an entire frame image, it would be unthinkably slow. So why do it here? Seems like a hack to get around slow code? If that's the case I would think that a fix will be hard because it means that the way it's done is fundamentally slow, and has already been "optimised" with this "do a bit, render, do a bit more, render" algorith.


hello.

well, they'er still in the future bits. btw, i think that the way to go is to use pagination and render them all at once (maybe changing the ui so that it is only shown when data is present - while it isn't, i think that showing an animated gif is more than enough).


On further analysis, I found that the listview performs much better on Mozilla FireFox than on IE 6.
So, I guess, the problem could be with IE's javascript engine rather than with the ListView itself.

Regards,
Tim

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.