This is a migrated thread and some comments may be shown as answers.

Data table issue

4 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Megan
Top achievements
Rank 1
Megan asked on 12 Dec 2008, 10:35 AM
We've got a radgrid bound to a dataset and a search text box on our web page. When the user inputs a code to the text box, we want the radgrid to find the row within the dataset and scroll down to it in the grid.
 
This was possible to do in standard VB.NET but we're having issues using telerik.

So far we have this logic:

 

   Protected Sub form1_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles form1.Load  
        cn = New SqlConnection(ConStr)  
        ds = New DataSet  
        dv = New DataView  
 
        Dim ad As New SqlDataAdapter("select * from mytable", cn)  
 
        ad.Fill(ds, "codeid")  
 
        dv.Table = ds.Tables("codeid")  
 
        RadGrid.DataSource = dv  
 
    End Sub 
 
    Protected Sub btnSearch_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnSearch.Click  
        Dim lpos As Integer 
 
        dv.Sort = "codeid" 
        lpos = dv.Find(btnSearch.Text)  
 
        'here we want to set current row to lpos  
 
        RadGrid.Rebind()  
 
    End Sub 

 

 

But when it comes to setting the data set's index we found the property was read only.

RadGrid2.SelectedItems.Item(0).DataSetIndex = 4

Property 'DataSetIndex' is 'ReadOnly'.

Is there another property we have to use instead to achieve the same effect of getting the grid to scroll down to the right place in the dataset position the user searched for?


 

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Dec 2008, 11:35 AM
Hi Megan,

Can you post your standard VB.NET? We will gladly translate you to RadGrid style.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Megan
Top achievements
Rank 1
answered on 12 Dec 2008, 12:20 PM


Imports System.Data  
 
Imports System.Data.SqlClient  
 
Public Class Form1  
 
    Private ds As DataSet  
    Private dv As DataView  
    Private ConStr As String = "Data Source=SERVER;Initial Catalog=DATABASE;User ID=sa" 
    Private cn As SqlConnection  
 
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
 
        cn = New SqlConnection(ConStr)  
        ds = New DataSet  
        dv = New DataView  
 
        Dim ad As New SqlDataAdapter("select * from mytable", cn)  
 
        ad.Fill(ds, "codeid")  
        dv.Table = ds.Tables("codeid")  
 
        Me.DataGridView1.DataSource = dv  
 
    End Sub 
 
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged  
 
        Dim strVal As String 
 
        strVal = Me.ComboBox1.Text  
        Label1.Text = "The data is sorted on column " & strVal  
        dv.Sort = "codeid" 
 
    End Sub 
 
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
        Dim lpos As Integer 
 
        dv.Sort = "codeid" 
        lpos = dv.Find(TextBox1.Text)  
        DataGridView1.CurrentCell = DataGridView1.Item("codeid", lpos)  
        '  DataGridView1.pos() ' = True '= lpos ' = DataGridView1.Item(lpos, 1)  
        'Find the customer named "Smith" in the primary key column  
        'Int(i = dv.Find("Smith"))  
 
    End Sub 
 
    Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged  
 
        Dim filtStr As String 
        filtStr = Me.ComboBox2.Text  
        Label1.Text = "The Data is Filtered for all Names starting with alphabet " & filtStr  
        dv.RowFilter = "Name like '" & filtStr & "*'" 
 
    End Sub 
 
End Class 
 


I assume only memebers of staff can add attachments to posts so I hope this is enough to work from.
0
Vlad
Telerik team
answered on 15 Dec 2008, 07:02 AM
Hi Megan,

As far as I know CurrentCell property is available in WinForms grid.

All the best,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Megan
Top achievements
Rank 1
answered on 15 Dec 2008, 09:47 AM
Is there no other way to achieve this? We don't have WinForms.

I don't understand why this property has to be readonly.
Tags
Grid
Asked by
Megan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Megan
Top achievements
Rank 1
Share this question
or