UpdateCommand with Datalist

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    UpdateCommand with Datalist

    Hi, I have a datalist that I use to display and edit records to a user.
    Datalist shown below;



    visual basic
    code:-----------------------------------------------------------------------
    -------
    <asp:datalist id="dgContribut ors" runat="server" DataKeyField="P ersonID">
    <ItemTemplate >
    <%# Container.DataI tem("FirstName" ) %>
    <asp:LinkButt on text="Select" CommandName="ed it" Runat="server"
    ID="Linkbutton1 " NAME="Linkbutto n1"></asp:LinkButton>
    </ItemTemplate>
    <EditItemTempla te>
    <asp:TextBox ID="txtFirstNam e" Text="<%# Container.DataI tem("FirstName" )
    %>" Runat="server" width="100px"></asp:TextBox>
    <asp:LinkButt on text="Enter" CommandName="up date" Runat="server"
    ID="Linkbutton2 " NAME="Linkbutto n1"></asp:LinkButton>
    </EditItemTemplat e>
    </asp:datalist>
    ----------------------------------------------------------------------------
    --

    I want to use the UpdateCommand to capture the new information entered into
    the textbox and place this information into a database.
    The code in the updateCommand is as follows


    visual basic
    code:-----------------------------------------------------------------------
    -------
    Private Sub dgContributors_ UpdateCommand(B yVal source As Object, ByVal e As
    System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
    dgContributors. UpdateCommand
    Dim oFirst As TextBox
    oFirst = e.Item.FindCont rol("txtFirstNa me")

    ' Should print out the new information entered into the textbox but does
    not. It prints out the previous information
    Response.write( oFirst.Text)

    End Sub
    ----------------------------------------------------------------------------
    --

    The problem I am having is even though the UpdateCommand fires the value of
    the textbox does not change to the newly entered information...

    Thanks for any help
    Cheers
    MarkusJ


  • Jos

    #2
    Re: UpdateCommand with Datalist

    "Mark" <mark@yahoo.com N0SPAM> wrote in message
    news:bf5c6m$vo4 $1@lust.ihug.co .nz...[color=blue]
    > The problem I am having is even though the UpdateCommand fires the value[/color]
    of[color=blue]
    > the textbox does not change to the newly entered information...[/color]

    My first guess: you are databinding again on postback.
    Use:
    If Not Page.IsPostBack Then
    <databinding code here>
    End If

    --

    Jos


    Comment

    • Mark

      #3
      Re: UpdateCommand with Datalist

      Hi, yep, that was it! Forgot the most basic part of the whole thing
      <sheepish grin>

      Thanks for your time
      Cheers
      Mark


      Comment

      Working...