By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,492 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,492 IT Pros & Developers. It's quick & easy.

Datagrid inserts blank space into textboxes?

P: n/a
Roy
Hey All,

Kind of a series of anomalies here with one root source, I believe. I
have an editable, paging datagrid.

1.When one clicks "edit" textboxes open up on row x, HOWEVER, if one
clicks "next page" the textboxes remain no matter which page you are
on. No error messages are shown.
2.After editing data, when one clicks "update" the page refreshes, but
*no* new data is actually loaded into the db. No error messages are
given.
3.If there exists data within an editable textbox and you click "edit,"
the fields on the same row have extra space (blank, empty space)
inserted into them which generates errors when I click "update" unless
I go through and delete the spaces.

Posted is my Update SUB below. Any suggestions are very much
appreciated.

*******************
Sub MyDataGrid_UpdateCommand(Sender As Object, E As
DataGridCommandEventArgs)

'Assign variables to columns
Dim voydoc As String = E.Item.Cells(2).Text
Dim poe As String = E.Item.Cells(3).Text
Dim poe_cnt As String = E.Item.Cells(4).Text
Dim ll_cnt As String = E.Item.Cells(5).Text
Dim assigned_to as String = CType(e.Item.Cells(6).Controls(0),
TextBox).Text
Dim assigned_dt as String = CType(e.Item.Cells(7).Controls(0),
TextBox).Text
Dim poe_recon_done as String = CType(e.Item.Cells(8).Controls(0),
TextBox).Text
Dim vdn_done as String = CType(e.Item.Cells(9).Controls(0),
TextBox).Text
Dim vdn_done_dt as String = CType(e.Item.Cells(10).Controls(0),
TextBox).Text
Dim final_appvl as String = CType(e.Item.Cells(11).Controls(0),
TextBox).Text
Dim final_appvl_dt as String = CType(e.Item.Cells(12).Controls(0),
TextBox).Text
Dim pod As String = E.Item.Cells(13).Text
Dim carrier_wv as String = CType(e.Item.Cells(14).Controls(0),
TextBox).Text
Dim notes as String = CType(e.Item.Cells(15).Controls(0), TextBox).Text

Dim objCommand As SqlCommand
Dim strSQLQuery As String

'Update command
strSQLQuery = "UPDATE [lla] " & _
"SET voydoc = N'" & voydoc.Trim & "', " & _

"poe = N'" & poe.Trim & "', " & _
"poe_cnt = '" & poe_cnt.Trim & "', " & _
"ll_cnt = '" & ll_cnt.Trim & "', " & _
"assigned_to = N'" & Replace(assigned_to.Trim, "'", "''") & "', " & _
"assigned_dt = '" & Replace(assigned_dt.Trim, "'", "''") & "', " & _
"poe_recon_done = '" & Replace(poe_recon_done.Trim, "'", "''") & "', "
& _
"vdn_done = '" & Replace(vdn_done.Trim, "'", "''") & "', " & _
"vdn_done_dt = '" & Replace(vdn_done_dt.Trim, "'", "''") & "', " & _
"final_appvl = '" & Replace(final_appvl.Trim, "'", "''") & "', " & _
"final_appvl_dt = '" & Replace(final_appvl_dt.Trim, "'", "''") & "', "
& _
"pod = '" & pod.Trim & "', " & _
"carrier_web_validation = '" & Replace(carrier_wv.Trim, "'", "''") &
"', " & _
"notes = N'" & Replace(notes.Trim, "'", "''") & "' " & _
"WHERE ISNULL(voydoc,'') = '" & voydoc.Trim & "' AND ISNULL(poe,'') =
'" & poe.Trim & "'"
MyConnection.Open()
objCommand = New SqlCommand(strSQLQuery, MyConnection)
objCommand.ExecuteNonQuery()
MyConnection.Close()

MyDataGrid.EditItemIndex = -1
MyDataGrid.DataBind()

BindData()

End Sub

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Roy
Anyone have any tips? At all?

:)

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.