UpdateCommand with Datalist

Discussion in 'ASP .Net' started by Mark, Jul 17, 2003.

  1. Mark

    Mark Guest

    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="dgContributors" runat="server" DataKeyField="PersonID">
    <ItemTemplate>
    <%# Container.DataItem("FirstName") %>
    <asp:LinkButton text="Select" CommandName="edit" Runat="server"
    ID="Linkbutton1" NAME="Linkbutton1"></asp:LinkButton>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtFirstName" Text="<%# Container.DataItem("FirstName")
    %>" Runat="server" width="100px"></asp:TextBox>
    <asp:LinkButton text="Enter" CommandName="update" Runat="server"
    ID="Linkbutton2" NAME="Linkbutton1"></asp:LinkButton>
    </EditItemTemplate>
    </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(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataListCommandEventArgs) Handles
    dgContributors.UpdateCommand
    Dim oFirst As TextBox
    oFirst = e.Item.FindControl("txtFirstName")

    ' 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
    Mark, Jul 17, 2003
    #1
    1. Advertising

  2. Mark

    Jos Guest

    "Mark" <0SPAM> wrote in message
    news:bf5c6m$vo4$...
    > The problem I am having is even though the UpdateCommand fires the value

    of
    > the textbox does not change to the newly entered information...


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

    --

    Jos
    Jos, Jul 17, 2003
    #2
    1. Advertising

  3. Mark

    Mark Guest

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

    Thanks for your time
    Cheers
    Mark
    Mark, Jul 17, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dawn
    Replies:
    1
    Views:
    475
    Daniel Bass
    Jul 28, 2003
  2. Learning SQL Server
    Replies:
    2
    Views:
    2,456
    Learning SQL Server
    Aug 7, 2003
  3. Nevyn Twyll
    Replies:
    8
    Views:
    1,833
  4. srathin

    DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand

    srathin, Apr 9, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    157
    srathin
    Apr 9, 2005
  5. srathin

    DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand

    srathin, Apr 9, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    149
    srathin
    Apr 11, 2005
Loading...

Share This Page