2 Replies - 7194 Views - Last Post: 26 May 2011 - 11:35 AM Rate Topic: -----

#1 saranjaga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-May 11

Datagridview with Button

Posted 25 May 2011 - 10:33 PM

I am doing project now.i am a beginner for vb.net.I display data from ms access database to datagridview.Now i want add Button in Datagridview in one coloumn and when i click the button it will display the particular record and i want to display the diagram for that data.

I am using filter.but it doesn't work.my code is
 Dim index As Integer
        index = ComboBox1.FindString(TextBox1.Text)
        ComboBox1.SelectedIndex = index
        Dim filtStr As String
        Dim dv As New DataView()
        filtStr = Me.ComboBox1.Text
        ' Label3.Text = "The Data is Filtered for all Names starting with alphabet " & filtStr
        dv.RowFilter = "Name like '" & filtStr & "*'"
        DataGridView1.DataSource = dv.RowFilter

it display empty datagridview please help me.

This post has been edited by modi123_1: 26 May 2011 - 06:40 AM
Reason for edit:: please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Datagridview with Button

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Datagridview with Button

Posted 26 May 2011 - 06:10 AM

As I see dv is empty (Dim dv As New DataView()), it is only instantiate it, but you don't assign any value. It is not quite clear what do you want to filter. The datagridView? You want to fetch some values from database based on the selection from the comboBox?
Was This Post Helpful? 0
  • +
  • -

#3 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

Re: Datagridview with Button

Posted 26 May 2011 - 11:35 AM

I don't want to confuse you but I always found it much easier to use a query to pull a record from a recordset.
If you're using LINQ this should be an easy task:

Dim nameIds = From cust In customers
                Select cust.CompanyName


Plug your variable that holds the content you're searching for into the query.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1