Grid Upate Problem

  • Thread starter vengala s reddy
  • Start date
V

vengala s reddy

I am using a simple grid with 4 columns
column0 int identity
column1 varchar

i am using the following code
Private Sub kbGrid_UpdateCommand(s As Object, e As
DataGridCommandEventArgs)
Dim MyCommand As SqlCommand
Dim strConn As New SqlConnection("****")

Dim id as TextBox = E.Item.cells(2).Controls(0)
Dim name as TextBox = E.Item.cells(3).Controls(0)

THE NAME.TEXT VALUE IS GETTING THE OLD VALUE INSTED OF THE CHANGED
DATA I TYPED IN THE TEXTBOX NAME, AM I MISSING SOMETHING HERE.

dim strUpdateStmt As String
strUpdateStmt ="UPDATE testGrid SET name = '" & name.text & "' WHERE
id =" & id.text
MyCommand = New SqlCommand(strUpdateStmt, strConn)

response.write(strUpdateStmt)
'strConn.Open()
'MyCommand.ExecuteNonQuery()
'kbGrid.EditItemIndex = -1
'strconn.close
'kbGrid.DataBind()
end sub
THANKS IN ADVANCE.
 
N

Natty Gur

Hi,

Probably you refill datagrid on post back. You need to use IsPostback to
determine if postback occur and fill your grid just on first call of the
page.


Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top