Solved

datagrid in vb.net

Posted on 2004-03-26
3
718 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

803 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