Update from gridView ItemTemplate

Discussion in 'ASP .Net' started by DavidC, Jun 9, 2010.

  1. DavidC

    DavidC Guest

    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
    --
    David
    DavidC, Jun 9, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    5,328
    Joe Fallon
    Sep 24, 2004
  2. ABC
    Replies:
    1
    Views:
    948
    Patirck Ige
    Oct 7, 2005
  3. =?Utf-8?B?RGFiYmxlcg==?=

    use data from second sqldatasource in gridview itemtemplate?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,055
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 21, 2006
  4. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    2
    Views:
    3,492
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 12, 2006
  5. Enricko Chivaldory

    Update from gridView ItemTemplate

    Enricko Chivaldory, Jul 17, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    603
    Enricko Chivaldory
    Jul 17, 2010
Loading...

Share This Page