Good stuff. I'm trying to build more generic filtering based on your code but I have a problem with more than 1 letter in a textbox I replaced "Contains" with "StartsWith" DataTable filteredTable = dt.AsEnumerable() .Where(r => r.Field<string>("lastname").StartsWith(txtBox.Text.Trim().ToUpper())) .CopyToDataTable();
and it works only when I type a single letter. I type "m" and it filters all names that starts with "m". I type "mo" and returns an error "No rows returned" even if there are names that starts with "mo". Any idea what could that be?
what may be happening is your filter is losing value on second postback. It may be sending only "o" instead of "mo". Put a breakpoint and see if that is the case. You need to preserve previous input to the filter textbox.
Zen and the art of software maintenance : rm -rf *
Maths is like love : a simple idea but it can get complicated.
no, textbox has both letters and actually postback doesn't fire while typing only when I click anywhere outside of the box. What confusing is that I get the message "The source contains no DataRows"... Not sure why Source? My databable has rows
actually the same problem is in your code as well. I just created a project and copied your code. When I typed "bu" in your Item filter, it didn't return any result even if the second in your list is "Bubble Gum"
I expected to be able to filter by multiple fields, but it only appears to filter once? For example, I filtered by Order = 101, then I thought I could filter by Item = c, but the C seemed to have no effect.
It is because the filtering does not act the same in the Order field as the Item field. You can enter 101 for the Order, which matches anywhere in the value, but entering C for Item means it starts with C.
it really account for the filter requirement ,but it relies on postback that much that may it posback to the server too frequently? I've seen some UI controllers do a good job , say, easy ui ,fine ui etc
Last Visit: 31-Dec-99 18:00 Last Update: 23-Jul-16 14:11