469,935 Members | 2,232 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,935 developers. It's quick & easy.

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="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
Nov 17 '05 #1
2 3382
Jos
"Mark" <ma**@yahoo.comN0SPAM> wrote in message
news:bf**********@lust.ihug.co.nz...
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
Nov 17 '05 #2
Hi, yep, that was it! Forgot the most basic part of the whole thing
<sheepish grin>

Thanks for your time
Cheers
Mark
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jim in Arizona | last post: by
6 posts views Thread by Paul | last post: by
5 posts views Thread by Peter W Johnson | last post: by
3 posts views Thread by Mirek Endys | last post: by
2 posts views Thread by susan.f.barrett | last post: by
reply views Thread by stuart_dent | last post: by
3 posts views Thread by Crazy Cat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.