none
data in existing gridview RRS feed

  • Question

  • I have a grid and this already have data like this

    Column3 Column4
    123     345
    1345    235

    now i want to add two more columns from textbox to grid e.g if i copy this data in textbox then want to add this data in grid

    excelcol1  excelcol2
       345        abc
      1234        abc

    how i do this ?

    i done with this

    Protected Sub Paste(sender As Object, e As EventArgs) Handles textData.TextChanged
        Try
            gridviewss.Columns.Add(New DataColumn(1) {New DataColumn("excelcol1", GetType(Integer)),
                                                    New DataColumn("excelcol2", GetType(String))})
            Dim cCon As String = Request.Form(textData.UniqueID)
            For Each row As String In cCon.Split(ControlChars.Lf)
                If Not String.IsNullOrEmpty(row) Then
                    gridviewss.Rows.Add()
                    Dim i As Integer = 0
                    For Each cell As String In row.Split(ControlChars.Tab)
                       If i > 1 Then
                           textData.Text = ""
                            Exit Sub
                        Else
                            If cell.Trim() = "" Then
                                cell = "0"
                            End If
                            gridviewss.Rows(gridviewss.Rows.Count - 1)(i) = cell
                            i += 1
                        End If
                    Next
                End If
            Next
        Catch ex As Exception
    
        End Try
    End Sub

    but tthis shows an error

    *Error 204 'Add' is not a member of 'System.Web.UI.WebControls.GridViewRowCollection'.

    Error 205 Class 'System.Web.UI.WebControls.GridViewRow' cannot be indexed because it has no default property.

    Error 203 Value of type '1-dimensional array of System.Data.DataColumn' cannot be converted to 'System.Web.UI.WebControls.DataControlField'.**

    Thursday, May 11, 2017 7:00 AM

All replies

  • Bes to ask here

    https://forums.asp.net/


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, May 11, 2017 3:45 PM
  • Hello,

    Since this forum is discussing and asking questions about the Visual Basic programming language, IDE, libraries, samples, and tools, and your issue is more related to asp.net. This link about asp.net, please refer that: https://forums.asp.net/

    Thank you for participating in the forum activities.

    Best Regards,

    Cherry



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 12, 2017 3:30 AM