Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 698881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:19:30+00:00 2026-05-14T03:19:30+00:00

I’ve got a gridview connected to an objectdatasource which is bound to some custom

  • 0

I’ve got a gridview connected to an objectdatasource which is bound to some custom objects in my code (code is below). The problem I’m having is that the value passed into my update method is the old value, not the new value. Thoughts?

Imports System.Configuration
Imports System.Web.Configuration
Imports System.Security.Cryptography
Imports System.Collections.Generic

Partial Public Class ManageUsersControl
    Inherits System.Web.UI.UserControl
    Dim auth As AuthenticationSection
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Users.DataBind()
    End Sub
End Class

Public Class Users
    Private sName As String
    Private sPassword As String

    Public Sub New()

    End Sub

    Public Sub New(ByVal nm As String, ByVal pass As String)

        Name = nm
        Password = pass
    End Sub

    Public Property Name() As String
        Get
            Return sName
        End Get
        Set(ByVal value As String)
            sName = value
        End Set
    End Property

    Public Property Password() As String
        Get
            Return sPassword
        End Get
        Set(ByVal value As String)
            sPassword = value
        End Set
    End Property
End Class

Public Class UserData
    Dim auth As AuthenticationSection
    Shared userTable As List(Of Users)

    Public Sub New()
        auth = CType(WebConfigurationManager.GetSection("system.web/authentication"), AuthenticationSection)
    End Sub

    Public Function CreateData() As List(Of Users)

        Dim dt As New List(Of Users)
        For Each user As FormsAuthenticationUser In auth.Forms.Credentials.Users
            dt.Add(New Users(user.Name, user.Password))
        Next

        userTable = dt

        Return userTable
    End Function

    Public Function SelectMethod() As List(Of Users)
        If userTable Is Nothing Then
            Return CreateData()
        Else
            Return userTable
        End If
    End Function

    Public Function UpdateMethod(ByVal userInfo As Users) As Integer
        Dim user As FormsAuthenticationUser = auth.Forms.Credentials.Users(userInfo.Name)
        Dim pass As String
        Dim sha As New SHA1CryptoServiceProvider()
        Dim enc As New System.Text.ASCIIEncoding()

        pass = enc.GetString(sha.ComputeHash(enc.GetBytes(userInfo.Password)))
        userTable.Add(New Users(userInfo.Name, pass))
        user.Password = pass
        Return 1
    End Function
End Class

and the markup:

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ManageUsers.ascx.vb" Inherits="mystuff.ManageUsersControl" %>

<asp:GridView ID="Users" runat="server" AutoGenerateColumns="False" 
    AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" 
    DataSourceID="UsersData">
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="User Name" />
        <asp:TemplateField HeaderText="Password" >
            <InsertItemTemplate>
                <asp:TextBox runat="server" ID="InsertPassword" Text='<%# Bind("Password") %>' />
            </InsertItemTemplate>
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="EditPassword" Text='<%# Bind("Password") %>' />
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label runat="server">*****</asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:ObjectDataSource ID="UsersData"
                      DataObjectTypeName="mystuff.Users" 
                      UpdateMethod="UpdateMethod"
                      SelectMethod="SelectMethod"
                      TypeName="mystuff.UserData"
                      runat="server" 
    OldValuesParameterFormatString="original_{0}"></asp:ObjectDataSource>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:19:30+00:00Added an answer on May 14, 2026 at 3:19 am

    Just found the solution.

    Partial Public Class ManageUsersControl
        Inherits System.Web.UI.UserControl
        Dim auth As AuthenticationSection
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then Users.DataBind()
        End Sub
    End Class
    

    Also, discovered that you can’t edit the users during execution of the application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.