Advertisement

05.31.2006 at 02:02PM PDT, ID: 21870304
[x]
Attachment Details

How to Get the gridview cell value of the selected row into a datatable

Asked by de1209 in Programming for ASP.NET

Tags: gridview, value, get, cell, row

I got a gridview in which i selected a row by clicking anywhere on the row and now i am trying to get a cell value of the selected row into a datatable.

I am getting an error saying " Input string was not in a correct format. " at the point given below (at ---->)

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(2).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

Can anyone help me with this

Start Free Trial
[+][-]05.31.2006 at 03:56PM PDT, ID: 16803360

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.01.2006 at 12:24AM PDT, ID: 16805297

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2006 at 01:21PM PDT, ID: 16819971

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2006 at 02:50AM PDT, ID: 16822861

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2006 at 11:48AM PDT, ID: 17124531

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.22.2006 at 08:01AM PDT, ID: 17160294

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Tags: gridview, value, get, cell, row
Sign Up Now!
Solution Provided By: DarthMod
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32