After editing some fields, clicking on Update doesn't show the new values. I have tried two ways to retrieve the new values as you can see from this shortened version of the ItemUpdating event (and both return the old ones) :-
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
Dim txtPassword As TextBox = CType(DetailsView1.Rows(1).Cells(1).FindControl("txtPassword"), TextBox)
Struct_Student.password = txtPassword.Text
Dim PasswordValue As String = e.NewValues("password").ToString()
Struct_Student.password = PasswordValue
End Sub
Here is a shortened version of the aspx :-
<asp:Content ID="Content1" ContentPlaceHolderID="cpMainContent" Runat="Server">
<div id="Controls">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DetailsView ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataKeyNames="student_id" DataSourceID="SqlDataSource1"
ForeColor="Blue"
BackColor="#FFF7E6"
AutoPostBack="True"
AutoGenerateEditButton = True
AutoGenerateInsertButton = True
OnModeChanging="StudentDetailView_ModeChanging"
Height=163px
Width=327px
style="left: 400px; top: 1px; position: absolute;">
<Fields>
<asp:TemplateField
HeaderText="Password">
<EditItemTemplate>
<asp:TextBox
id="txtPassword"
Text = '<%# Bind ("password") %>'
runat = "server" />
<asp:RequiredFieldValidator
ID = "reqPassword"
ControlToValidate = "txtPassword"
Text = "(required)"
Display = "Dynamic"
runat = "server" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label
id="PasswordLabel"
runat="server"
Text = '<%# Eval("password") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField
datafield="emailaddress"
headertext="Email address"
SortExpression="emailaddress"
/>
</Fields>
</asp:Detai开发者_C百科lsView>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:FCLManager %>" ProviderName="MySql.Data.MySqlClient"
SelectCommand="Select * from tblstudentinfo WHERE centre_id = @CentreID and fullname = @FullName"
<SelectParameters>
<asp:Parameter Name="CentreID" Type="Int16" DefaultValue="0" />
<asp:Parameter Name="FullName" Type="String" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</div> <%--Controls div--%>
</asp:Content>
精彩评论