all groups > dotnet windows forms databinding > january 2005 >
You're in the

dotnet windows forms databinding

group:

Implementing a find nearest


RE: Implementing a find nearest v-jetan NO[at]SPAM online.microsoft.com (
1/12/2005 8:59:35 AM
dotnet windows forms databinding: Hi James,

Thanks for your posting!

Based on my understanding, you want to implement the search function in
your ADO.net application, your issue is how to implement the "Find Next"
feature in your app. If I misunderstand you, please feel free to tell me.

After setting RowFilter property for dataview, the dataview will contain
the filtered child view with the filter condition. So we may Sort property
to sort the filtered view, and just return the first DataRowView for the
first search. Then we may store an static index and the dataview of the
filtered view. For the "Search Next" request, we may just add 1 to the
static index and return the next item(DataRowView) in the stored dataview.
All will work well.

Hope this helps.
=================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Implementing a find nearest James Sugrue
1/12/2005 4:02:57 PM
I have a form which is the result of using the Data Form Wizard. I have
added a text box which allows the user to search for a record and go for
the nearest record. For example if the user where searching for product
name and typed "W" it would go to the first record that starts with W.

When the user clicks a button I do the following:

1) Create a dataview from the dataset used by the databound controls.
2) Set a filter with "DataColumn like '" + searchboxtext + '%'"

this works fine and returns a DataView with the appropriate data.

How do I now relate this to the original databound dataset and change
the row to the appropriate row. I know you can use
BindingContext.Position, but how is the position in the dataview related.

Maybe there is a better way to implement a find/search and move to the
Re: Implementing a find nearest v-jetan NO[at]SPAM online.microsoft.com (
1/13/2005 9:01:32 AM
Hi James,

Thanks for your feedback!

In ADO.net, DataSet is a connection-less .Net class object, which is
different from ADO's recordset object, which still has the connection with
the database table. The position concept in recordset is because of the
connection with the database table. There is no position concept in DataSet
or in DataView, so in the last reply, I suggest you use a static field to
maintain a position variable yourself.

That is, in your situation, we may use DataView.Find method or RowFilter
property to return a collection of rows, then use a customized position
variable to index through this collection.

Hope this makes sense to you.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: Implementing a find nearest James Sugrue
1/13/2005 9:22:22 AM
[quoted text, click to view]

I'm not sure I explained that well. I'll try again.

I have a form that is the result of the Data Form Wizard. This creates
the usual CRUD buttons and buttons to navigate the dataset.

On the form I have put another textbox which users can enter a partial
search and click find.

I have implemented a sort and filter using a dataview based on the bound
dataset. This finds the record ok.

EG

DataView dv = objdsTransport.Tables[0].DefaultView;
dv.RowFilter = "TransportCo like '" + txtSearch.Text + "*'";

So I have this dataview how do I now position objdsTransport so that it
goes to the appropriate position.

I thought I could go
string strCoName = dv[0].Row[0].ToString();
objdsTransport.Tables[0].Rows.Find("TransportCo = '" + strCoName + '";

this also works but it returns a datarowcollection which is no good to
me, because I want to position the dataset to the record like seek used
to do under ADO.

I am guessing I have to use bindingcontext.postion or something like
that but cant seem to work it out.
AddThis Social Bookmark Button