UpdateCommand not seeing value
I've used the datagrid to update data quite extensively without a
problem. However, I've run into a situation where it isn't working and
either I'm missing something terribly obvious or there is some sort of
bug causing it not to work.
I have a 2 column datagrid that I'm loading and binding fine. Delete
works fine. However, when I update (using default edit capabilities, not
using template columns), the control that I get back from the grid is
empty when it should contain the new user entered data. Here is the
Private Sub datagridClients_UpdateCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
Dim con As New SqlConnection(Constants.Connection_DB)
Dim cmd As New SqlCommand()
Dim txt As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
' at this point, txt.text = "" even though the user
' has entered data into the text box in the datagrid
cmd.Connection = con
cmd.CommandText = "update MyTable " & _
" set Client_Name = '" & txt.Text & "' " & _
" where Client_ID = " & e.Item.Cells(0).Text
datagridClients.EditItemIndex = -1
Catch ex As Exception
' Error Code here
If Not cmd Is Nothing Then cmd.Dispose()
If Not con Is Nothing Then
If con.State = ConnectionState.Open Then con.Close()
I'm 99.99% sure my code is right (I copied it from a working page). Is
there some event or option that can cause the text box control object
not to pass its value in to the updatecommand event? Are there any other
things I should look at to figure out why my e.Item.Cells(1).Controls(0)
object doesn't have any values?
Re: UpdateCommand not seeing value
Disregard. Looks like an errant </form> tag got stuck in my header
template and was closing the form well before all my controls!
|All times are GMT. The time now is 02:01 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.