Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
nm = CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text
sal = Convert.ToDouble(CType(GridView1.Rows(e.RowIndex).Cells(3).Controls(0), TextBox).Text)
conn.Open()
cmd = New SqlCommand
cmd.CommandText = "update emptb set name=@e2,salary=@e3 where code=@e1"
cmd.Parameters.Add("@e1", SqlDbType.Int).Value = GridView1.DataKeys(e.RowIndex).Value(0)
cmd.Parameters.Add("@e2", SqlDbType.NVarChar).Value = nm
cmd.Parameters.Add("@e3", SqlDbType.Money).Value = sal
cmd.Connection = conn
cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Close()
GridView1.EditIndex = -1
bind()
Public Sub bind()
adp = New SqlDataAdapter("select * from emptb", str)
ds = New DataSet
adp.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
ds.Clear()
adp.Dispose()
End Sub
html code is:
i used emptb=table with three fields code,name, salary please tell me solution as soon as posible.