I am doing the school project for ASP.net in Visual Basic and trying to do the updating through gridview but somehow doesn't work at all.

Mind to help.....?

Dim ProductName, SupplierID As String
        Dim qty, price As Integer
        REM Dim key As Integer = GridView1.DataKeys.Item(e.RowIndex).Value
        Dim tb As TextBox

        tb = CType(GridView1.Rows(e.RowIndex.ToString).Cells(2).Controls(0), TextBox)
        ProductName = tb.Text

        tb = CType(GridView1.Rows(e.RowIndex.ToString).Cells(3).Controls(0), TextBox)
        SupplierID = tb.Text

        tb = CType(GridView1.Rows(e.RowIndex.ToString).Cells(4).Controls(0), TextBox)
        qty = Convert.ToInt32(tb.Text)

        tb = CType(GridView1.Rows(e.RowIndex.ToString).Cells(5).Controls(0), TextBox)
        price = Convert.ToInt32(tb.Text)



        Dim r As Dataedit.ProductsRow

        r.ProductName = ProductName
        r.SupplierID = SupplierID
        r.QuantityPerUnit = qty
        r.UnitPrice = price


        GridView1.EditIndex = -1
        GridView1.DataBind()

>trying to do the updating through gridview but somehow doesn't work at all.

Execute update query or invoke Update method of DataAdapter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.