?
Solved

Getting the value of cell in gridview when a row is selected

Posted on 2006-05-31
7
Medium Priority
?
227 Views
Last Modified: 2010-07-27
Can anyone help me in getting - value of cell in to some variable in gridview when a row is selected by clicking it anywhere on the row. I selected the row by ___doPostBack() method.



0
Comment
Question by:de1209
  • 3
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16802636
       gv.SelectedRow.Cells[0].Text
0
 

Author Comment

by:de1209
ID: 16802712
Hi lem2802 ,
This is actually my code:

Private Sub CreateSelectionAsSessionTable()
        Dim dt As New DataTable
        Dim drow As DataRow

        dt.Columns.Add(New DataColumn("PremiseId", GetType(Integer)))
        dt.Columns.Add(New DataColumn("CustomerId", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Addressline1", GetType(String)))
        dt.Columns.Add(New DataColumn("Name1", GetType(String)))
        dt.Columns.Add(New DataColumn("HomePhoneNumber", GetType(String)))
        dt.Columns.Add(New DataColumn("WorkPhoneNumber", GetType(String)))

        drow = dt.NewRow()

        Dim i As Integer = gvSelectAddress.SelectedIndex

        If i = -1 Then i = 1

        drow("PremiseId") = CType(gvSelectAddress.SelectedRow.Cells(1).Text, Integer)
        drow("addressline1") = gvSelectAddress.Rows(i).Cells(7).Text
        drow("name1") = gvSelectAddress.Rows(i).Cells(8).Text
        drow("HomePhoneNumber") = gvSelectAddress.Rows(i).Cells(9).Text
        drow("WorkPhoneNumber") = gvSelectAddress.Rows(i).Cells(10).Text

        dt.Rows.Add(drow)

        Sessions.SelectedDataTable = dt

    End Sub

I am trying to get the selected cell value in this datatable. The cell is in the first column of the selected row.
0
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16802803
this work?

        drow("PremiseId") = gvSelectAddress.SelectedRow.Cells(1).Text
        drow("addressline1") = gvSelectAddress.SelectedRow.Cells(7).Text
        drow("name1") = gvSelectAddress.SelectedRow.Cells(8).Text
        drow("HomePhoneNumber") = gvSelectAddress.SelectedRow.Cells(9).Text
        drow("WorkPhoneNumber") = gvSelectAddress.SelectedRow.Cells(10).Text
0
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!

 

Author Comment

by:de1209
ID: 16803130
 dt.Columns.Add(New DataColumn("PremiseId", GetType(Integer)))

The value for column premiseId here is Integer

gvSelectAddress.SelectedRow.Cells(1).Text  
this should be converted to integer.
Here the grid is in the master page

0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 1500 total points
ID: 16805304
drow("PremiseId") = Convert.ToInt16(gvSelectAddress.SelectedRow.Cells(1).Text) Should do the trick as I said in your other topic as well..

Regards,
Max.
0
 

Author Comment

by:de1209
ID: 16808708


drow("PremiseId") = Convert.ToInt16(val(gvSelectAddress.SelectedRow.Cells(1).Text) )

worked fine.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 16809068
Glad to have been helpfull...

Regards,
Max.
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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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