Results 1 to 4 of 4
  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006

    Exclamation click datagrid row and display details to another datagrid

    hello there..here i need help. i have a datagrid that retrieve data from database.what i want to do with the datagrid is when i click any rows of the datagrid it can display the details of the data (refer to the row that i click) to another datagrid.

    is there possible to be done ?

    i want to know if there is any procedure that can capture the datagrid row that i clicked

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Sharjah, United Arab Emirates

    Re: click datagrid row and display details to another datagrid

    this should give you the selected cell's content
    VB Code:
    1. Private Sub DataGrid1_Click()
    2.     DataGrid1.Col = DataGrid1.Col
    3.     DataGrid1.Row = DataGrid1.Row
    4.     MsgBox DataGrid1.Text
    5. End Sub
    But why do you want to display the contents in the other datagrid...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.

  3. #3
    New Member
    Join Date
    Feb 2010

    Re: click datagrid row and display details to another datagrid

    write this code inside a button:
    first set your autogeneratecolumn in datagrid to true if it is false it won't work
    Dim con As New SqlConnection
    Dim cmd As New SqlDataAdapter
    Dim ds As New DataSet
    'Dim dbfile As String
    'dbfile = Server.MapPath("cas_data.mdb")
    con = New SqlConnection("Server=(local);Database=Project;Integrated Security=SSPI")

    If IsPostBack = True Then
    Dim str As String
    ' Select the checkboxes from the GridView control
    Dim i As Integer
    For i = 0 To GridView1.Rows.Count - 1 'Step i + 1
    Dim row As GridViewRow = GridView1.Rows(i)
    Dim isChecked As Boolean
    isChecked = (CType(row.FindControl("CheckBox1"), CheckBox)).Checked

    If (isChecked) Then
    str = GridView1.Rows(i).Cells(1).Text
    cmd = New SqlDataAdapter("select Item_Code,Item_Des,Uom from Eng_Part_Master where (Item_Code='" & str & "')", con)
    cmd.Fill(ds, "Eng_Part_Master")
    GridView2.DataSource = ds

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Bristol, UK

    Re: click datagrid row and display details to another datagrid

    Welcome to VBForums felsi

    Unfortunately your post is irrelevant for a couple of reasons... first of all this is our VB6 forum, but the code you posted is for VB.Net (VB2002 and later), so the code wont work.

    The other reason is that the question was asked in 2006, so it is very unlikely that the original poster still needs help with it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width