Solved

datagrid in vb.net

Posted on 2004-03-26
3
725 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Six Sigma Control Plans
Progress

719 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