Använder en repeater för att skriva ut poster från accessdatabas till textboxar för att kunna uppdatera uppgifter. Men när jag sen requestar textboxarna för att uppdatera så resulterar det bara i tomma fält i dom kolumner som ska uppdateras. Vad är det som är fel? Här nedan förljer koden:Update
<script>
Public Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("databases/ForumDB.mdb;Persist Security Info=False;"))
Dim myAdapter = New OleDbDataAdapter("SELECT * FROM [tblMember] WHERE [Username] = '" & Session("user") & "'", myConnection)
Dim ds = New DataSet()
myAdapter.Fill(ds, "tblMember")
myRepeaterUserInfo.DataSource = ds.Tables("tblMember").DefaultView
myRepeaterUserInfo.DataBind()
End Sub
'Update author information...
Private Sub cmdUpdateAuthor_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdateAuthor.Click
Dim strPassword = Replace(Request.Form("txtPasswordUpdate"), " '", "''")
Dim strFname = Replace(Request.Form("txtFnameUpdate"), " '", "''")
Dim strLname = Replace(Request.Form("txtLnameUpdate"), " '", "''")
Dim strEmail = Replace(Request.Form("txtEmailUpdate"), " '", "''")
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("databases/ForumDB.mdb;Persist Security Info=False;"))
Dim mySelectQuery As String = "UPDATE [tblMember] SET [Password] = '" & strPassword & "',[Fname] = '" & strFname & "',[Lname] = '" & strLname & "',[Email] = '" & strEmail & "' WHERE [Username] = '" & Session("user") & "'"
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
myConnection.Open()
Try
myCommand.ExecuteNonQuery()
Response.Redirect("Settings.aspx?update=yes")
Finally
myConnection.Close()
End Try
End Sub
</script
<table class="tablebox">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<asp:Repeater ID="myRepeaterUserInfo" runat="server"><ItemTemplate>
<tr>
<td width="150"><span class="fieldtext">Användarnamn:</span></td>
<td width="170"><asp:TextBox ID="txtUsernameUpdate" runat="server" Width="160px" Text='<%#DataBinder.Eval(Container,"DataItem.Username")%>' ReadOnly="true" CssClass="txtBox"></asp:TextBox></td>
<td> </td>
</tr>
<tr>
<td width="150"><span class="fieldtext">Lösenord:</span></td>
<td width="170"><asp:TextBox ID="txtPasswordUpdate" Runat="server" Width="160px" TextMode="Password" CssClass="txtBox"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="vldPassword" runat="server" ErrorMessage="Obligatorisk" ControlToValidate="txtPasswordUpdate" CssClass="errorTxt"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="vldPassword2" runat="server" ErrorMessage="Password must be 4 to 10 characters" ValidationExpression="\w{4,10}" ControlToValidate="txtPasswordUpdate" CssClass="errorTxt"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td width="150"><span class="fieldtext">Upprepa lösenord:</span></td>
<td width="170"><asp:TextBox ID="txtPasswordRetype" Runat="server" Width="160px" TextMode="Password" CssClass="txtBox"></asp:TextBox></td>
<td><asp:CompareValidator ID="vldPasswordRetype" runat="server" ErrorMessage="Your password does not match" ControlToCompare="txtPasswordUpdate" ControlToValidate="txtPasswordRetype" CssClass="errorTxt"></asp:CompareValidator></td>
</tr>
<tr>
<td width="150"><span class="fieldtext">Förnamn:</span></td>
<td width="170"><asp:TextBox ID="txtFnameUpdate" Runat="server" Width="160px" Text='<%#DataBinder.Eval(Container,"DataItem.Fname")%>' CssClass="txtBox"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="vldFname" runat="server" ErrorMessage="Obligatorisk" ControlToValidate="txtFnameUpdate" CssClass="errorTxt"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td width="150"><span class="fieldtext">Efternamn:</span></td>
<td width="170"><asp:TextBox ID="txtLnameUpdate" Runat="server" Width="160px" Text='<%#DataBinder.Eval(Container,"DataItem.Lname")%>' CssClass="txtBox"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="vldLname" runat="server" ErrorMessage="Obligatorisk" ControlToValidate="txtLnameUpdate" CssClass="errorTxt"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td width="150"><span class="fieldtext">Email:</span></td>
<td width="170"><asp:TextBox ID="txtEmailUpdate" Runat="server" Width="160px" Text='<%#DataBinder.Eval(Container,"DataItem.Email")%>' CssClass="txtBox"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="vldEmail" runat="server" ErrorMessage="Obligatorisk" ControlToValidate="txtEmailUpdate" CssClass="errorTxt"></asp:RequiredFieldValidator></td>
</tr></ItemTemplate></asp:Repeater>
<tr>
<td colspan="2"><asp:Button ID="cmdUpdateAuthor" Text="Uppdatera" Runat="server"></asp:Button></td>
</tr>
</table><br />
</table>