Move to a specific row in a datagrid

Tristan

Member
Joined
Feb 14, 2005
Messages
5
Programming Experience
Beginner
Hi to all!

Suppose to have a bound datagrid of more than 1000 rows (and some columns) displayed in a single web form!
After loading the page I need to specify a column, enter a value in a textbox and then click on a SEARCH button.
I need that the first row that satisfy my parameters will be selected and highlighted.

Is this possible in .Net 1.1?

TNX.
 
I used a simple "for loop" and I did it ... but there is a better solution?

Then, with this huge grid IE shows the vertical scroll bar, but selecting a row didn't move this bar down!
 
Last edited:
I've used a data view to move to a grid record

This code is set on a mouseup event of a grid to move to the corresponding record on another grid.
when you click on a delivery, it will move to the record in the part grid for that delivery part id.
("part id") is the primary key on the DV.Sort line.

Dim partpointer As Integer
Dim DV As DataView
Dim I As Integer
If Me.BindingContext(DsDeliveries1, "Delivery").Count > 0 Then
If Not DeliveriesGrid.Columns("part id").Value Is DBNull.Value Then
If DeliveriesGrid.Columns("part id").Value > 0 Then
partpointer = DeliveriesGrid.Columns("part id").Value
DV = New DataView(DsPartDeliveries1.Tables("part"))
DV.Sort = ("part id")
I = DV.Find(partpointer)
Me.BindingContext(DsPartDeliveries1, "part").Position = I
End If
Else
End If
Else
End If

It is another way to do it...
 
TPM said:
Why not just use a WHERE in your SQL select?

TPM

I need to show ALL the data and then give a quick way to find specified info ... but maybe I didn't understand you!


David, your way works only if I search throu the column with the primary key. Teorically, I will need to search throu every columns!
 
Last edited:
This code is possible help you for your search. For me work very well. Filter data without use Dataview

VB.NET:
...Declare dst,dta....
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim clave As String = Trim(Me.txtFind.Text) 'Your find TextBox
Me.con.ConnectionString ="..your connection string..." 
dta = New SqlDataAdapter("Select * from YourTable where Field1 LIKE '" & clave & "%' OR Field2 LIKE '%" & clave & "%' [i]..another .[/i]. order by DoyouWant", con)
Dim oCB As SqlCommandBuilder = New SqlCommandBuilder(dta)
dst = New DataSet
dta.Fill(dst, "YourTable")
Me.myGrid.DataSource = dst
Me.myGrid.DataMember = "YourTable"
con.Close()
  End Sub

JVAF
 
Back
Top