Search for most matching data in Dataview  
Author Message
carol chen





PostPosted: .NET Framework Data Access and Storage, Search for most matching data in Dataview Top

Hi

I've loaded my Excel file into a dataset and created a dataview. Now I want to filter the dataview according to the user input. What I want to know is that can I search for the most matcing item For example, there is a column in my dataview called "Length" which includes 4, 6, 8, 9, 10, 11, 12, 13. If user input is 5, I wanna search for next longer length which is 6, anyone knows how can I do it Many thanks in advance......

Carol




.NET Development2  
 
 
iamunmad





PostPosted: .NET Framework Data Access and Storage, Search for most matching data in Dataview Top

u can use a while loop to meet your requirement. Set the DataView RowFilter property and increase the value by 1 until u get the next row

Like:

int length = int.Parse(textbox1.text);

while ( true )

{

DataView1.RowFilter = "Length = " + length;

if ( DataView1.Count > 0 )

break;

else

length++;

}



 
 
carol chen





PostPosted: .NET Framework Data Access and Storage, Search for most matching data in Dataview Top

great, i've tried and it works....thank you very much!!!! but do have another problem though. since my search is quite complicated and have several different dataviews, do you know that can I bind datagridview to multiple dataviews can a dataview hold previous views (i guess not) or do I have to dump all viewrows to a datatable which can be finally bound to this is what I did at the moment that using the databindings, but have no luck.

DataGridView1.DataBindings.Add(New Binding("", dv, ""))