Solved

datagrid in vb.net

Posted on 2004-03-26
3
717 Views
Last Modified: 2012-05-04
HOW TO RETRIVE  SELECTED ROW VALUES OF A  DATAGRID IN VB.NET(NOT C#OR ASP.NET)
0
Comment
Question by:anu2004
  • 3
3 Comments
 
LVL 3

Expert Comment

by:pamboo
ID: 10693858
To get the selected cell value

 Me.DataGrid1.Item(_dgrid.CurrentCell())

- Rajan
0
 
LVL 3

Accepted Solution

by:
pamboo earned 20 total points
ID: 10693863
Sorry , u asked for the selected row  . The below function will return the datagrid selected row .

Public Function GetSelectedRow() As DataRow

        Dim dv As DataView = _dgrid.DataSource
        Dim dsTemp As New DataSet
        Dim dr As DataRow
        Dim i As Integer

        dsTemp.Merge(dv.Table)

        If Not dv Is Nothing Then

            If _dgrid.CurrentRowIndex <> -1 Then

                dr = dsTemp.Tables(0).Rows(_dgrid.CurrentRowIndex)

                For i = 0 To dv.Table.Columns.Count - 1
                    dr.Item(i) = _dgrid.Item(_dgrid.CurrentRowIndex, i)
                Next                

                Return dr

            End If

        End If

        Return Nothing

End Function

- Rajan
0
 
LVL 3

Expert Comment

by:pamboo
ID: 10693886
say _dgrid is my datagrid control.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
autoit - check if option is checked in another program 2 106
java  and programming certification ? 4 86
Help to convert powershell script into a gui 9 135
Java Loop 6 48
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now