in

vb.net datagrid row select

i have a datagrid populated by a dataset
i want to check for a particular row in the dataset. if the exact number exist then select that row other wise show me the nearest match ie if i type 7001 and there is no record matching 7001 then it should select 700

My Code is attached below            
       Dim tt As Integer
                    tt = grdac_chart.CurrentRowIndex
                    grdac_chart.UnSelect(tt)
                    dtEmployee.PrimaryKey = New DataColumn() {dtEmployee.Columns("accountref")}
                    dtEmployee.DefaultView.Sort = "accountref"
                        If dtEmployee.Rows.Contains(txtNo.Text) Then
                            Dim init_rows As Integer
                            init_rows = ProductData.Tables(0).DefaultView.Find(txtNo.Text)
                            grdac_chart.CurrentRowIndex = init_rows
                            grdac_chart.Select(init_rows)
                        End If
Movie Stars

Solution: vb.net datagrid row select

please try to use the DataView's RowFilter and Sort properties...
1:
2:
3:
4:
ProductData.Tables(0).DefaultView.RowFilter = "'7001' LIKE accountref + '%'" 
ProductData.Tables(0).DefaultView.Sort = " LEN(accountref) DESC "
 
and the first row returned should give you the best match, if any