Update from gridView ItemTemplate


D

DavidC

I have a simple GridView with multiple columns from a Sql table. I have only
1 data column that I want to update (a date column) without having to have
the user click an Edit button, edit the date and click the update button. I
have the GridView wrapped in an UpdatePanel and have the code below in the
TextChanged event of the TextBox. I think it may work if I can get the key
value of the row I am on. Any help is appreciated. Thanks.

Protected Sub txtCompleteDate_TextChanged(ByVal sender As Object, ByVal
e As System.EventArgs)
Dim intKey As Int32 = 0

Dim tb As TextBox = CType(sender, TextBox)
Dim dtNewDate As Date = Convert.ToDateTime(tb.Text)
Using conData As SqlConnection = New
SqlConnection(DBClass.GetCoreConnectionString)
conData.Open()
Dim strSQL As String = "UPDATE dbo.ApplicantRequirements" & _
" SET CompleteDate='" &
dtNewDate.ToShortDateString & "'" & _
" WHERE ApplicantReqID = " & intKey.ToString
End Using

End Sub
 
Ad

Advertisements


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