Child gridview update event
I have problem regarding child gridview (gridview inside ListView), so far
i solved the databind and the the Delete command , but i couldn't figure
out the Edut Mode ( i click the image button) but the GV doesn't go to
edit mode the codes are as follows: thanks in advance
Page mark-up:
EditItemTemplate
<asp:ImageButton ID="imgbUpdate" runat="server" CommandName="Update"
Text="Update" ImageUrl="~/Images/save_icon_mono.gif"
CausesValidation="true" ValidationGroup="vgrpSaveContact"/>
<asp:ImageButton ID="imgbCancel" runat="server" CommandName="Cancel"
Text="Cancel" ImageUrl="~/Images/undo_icon_mono.gif"
CausesValidation="false"/>
EditItemTemplate
<ItemTemplate>
<table>
<tr>
<td> <asp:ImageButton ID="imgbEdit" runat="server"
CommandName="Edit" Text="Edit"
ImageUrl="~/Images/edit_icon_mono.gif" />
</td>
<td> <asp:ImageButton ID="imgbDelete" runat="server"
CommandName="Delete" Text="Delete"
ImageUrl="~/Images/delete_icon_mono.gif" ToolTip="Delete"/>
</td>
</tr>
</table>
</ItemTemplate>
Code VB.NET
Protected Sub gvSorties_RowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)
Dim connString As String =
ConfigurationManager.ConnectionStrings("MoyensAeriensConnectionString").ConnectionString
Dim gvTemp As GridView = DirectCast(sender, GridView)
gvUniqueID = gvTemp.UniqueID
'Get the value
Dim strSortieID As String =
DirectCast(gvTemp.Rows(e.RowIndex).FindControl("lblSortieID"),
Label).Text
Using conn As New SqlConnection
conn.ConnectionString = connString
conn.Open()
Try
Dim strSQL As String = ""
Dim dsTemp As New SqlDataSource()
dsTemp.ConnectionString = connString
'Get the values stored in the text boxes
Dim strMissionNo As String =
DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtMissionNo"),
TextBox).Text
Dim strCaptain As String =
DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtCaptain"),
TextBox).Text
Dim strCrew As String =
DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtCrew"),
TextBox).Text
Dim strFuel As String =
DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtFuel"),
TextBox).Text
'Prepare the Update Command of the DataSource control
strSQL = "UPDATE Sortie set MissionNo = '" & strMissionNo &
"'" & ",Captain = " & strCaptain & "" & ",Crew = '" & strCrew
& "'" & ",Fuel = '" & strFuel & "'" & " WHERE SortieID = " &
strSortieID
dsTemp.UpdateCommand = strSQL
dsTemp.Update()
'Reset Edit Index
gvEditIndex = -1
lvODV.DataBind()
conn.Close()
Catch
End Try
End Using
End Sub
Many thanks to every one
No comments:
Post a Comment