Row Update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krisssgopi
    New Member
    • Apr 2010
    • 39

    #1

    Row Update

    Hi team,

    i am using grid view row updating method. It was throwing an exception object reference not set to an instance. please advice me on which it was going wrong. please suggest me any other way to fix it.

    Code:
    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
            Dim textbox1, textbox2, textbox3 As New TextBox
            'GridViewRow(row = GridView1.Rows(e.RowIndex))
            Dim row As GridViewRow
            row = GridView1.Rows(e.RowIndex)
            textbox1 = row.FindControl("textbox1")
            textbox2 = row.FindControl("textbox2")
            textbox3 = row.FindControl("textbox3")
            'doupdate(textbox1, textbox2, textbox3)
            con.Open()
            cmd = New MySqlCommand("insert into login where username='" & textbox1.Text & "','" & textbox2.Text & "','" & textbox3.Text & "'", con)
            da = New MySqlDataAdapter(cmd)
            ds = New DataSet
            cmd.ExecuteNonQuery()
            MsgBox("inserted successfully...")
            da.Fill(ds)
            GridView1.DataSource = ds
            GridView1.DataBind()
        End Sub
Working...