G
Guest
I have a page that shows some data in a datagrid. All rows are updateable
and then the changes are saved by hitting the "Save Changes" button. It is
not a row by row save. All edits are made and then all altered rows are
saved at once. It can be big, so I only want to save the ones that have
changed. I'm keeping track of the changed rows in ViewState with this code:
Protected Sub RowChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim intRowIndex As Integer
colRowsChanged = ViewState("RowsChanged")
intRowIndex = dgPhoneNumbers.DataKeys(CType(CType(sender,
Control).NamingContainer, DataGridItem).ItemIndex)
If Not colRowsChanged.Contains(intRowIndex) Then
colRowsChanged.Add(intRowIndex)
End If
ViewState("RowsChanged") = colRowsChanged
End Sub
This Sub is called from each textbox's OnTextChanged event like this:
<asp:TextBox ID="txtDisplayName" Text='<%#
Container.DataItem("DisplayName")%>' Columns="20" MaxLength="40"
OnTextChanged="RowChanged" AutoPostBack="True" runat="server" />
It all works fine, except that the RowChanged sub only fires when the row
change is followed by a tab or specifically clicking away from the textbox.
This causes a problem if someone changes a few rows and directly clicks "Save
Changes" without purposefully clicking away from the textbox first. Most
users are going to just click "Save Changes" after making the last change, so
this is causing problems.
Is there another way to fire this Sub? Or other suggestions.
Thanks.
and then the changes are saved by hitting the "Save Changes" button. It is
not a row by row save. All edits are made and then all altered rows are
saved at once. It can be big, so I only want to save the ones that have
changed. I'm keeping track of the changed rows in ViewState with this code:
Protected Sub RowChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim intRowIndex As Integer
colRowsChanged = ViewState("RowsChanged")
intRowIndex = dgPhoneNumbers.DataKeys(CType(CType(sender,
Control).NamingContainer, DataGridItem).ItemIndex)
If Not colRowsChanged.Contains(intRowIndex) Then
colRowsChanged.Add(intRowIndex)
End If
ViewState("RowsChanged") = colRowsChanged
End Sub
This Sub is called from each textbox's OnTextChanged event like this:
<asp:TextBox ID="txtDisplayName" Text='<%#
Container.DataItem("DisplayName")%>' Columns="20" MaxLength="40"
OnTextChanged="RowChanged" AutoPostBack="True" runat="server" />
It all works fine, except that the RowChanged sub only fires when the row
change is followed by a tab or specifically clicking away from the textbox.
This causes a problem if someone changes a few rows and directly clicks "Save
Changes" without purposefully clicking away from the textbox first. Most
users are going to just click "Save Changes" after making the last change, so
this is causing problems.
Is there another way to fire this Sub? Or other suggestions.
Thanks.