Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > UpdateCommand with Datalist

Reply
Thread Tools

UpdateCommand with Datalist

 
 
Mark
Guest
Posts: n/a
 
      07-17-2003
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


 
Reply With Quote
 
 
 
 
Jos
Guest
Posts: n/a
 
      07-17-2003
"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


 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      07-17-2003
Hi, yep, that was it! Forgot the most basic part of the whole thing
<sheepish grin>

Thanks for your time
Cheers
Mark


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand srathin ASP .Net Web Controls 2 04-10-2005 11:07 PM
DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand srathin ASP .Net Datagrid Control 0 04-09-2005 03:05 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
REPOST: Column [blah] is readonly on Datagrid UpdateCommand event Learning SQL Server ASP .Net 2 08-07-2003 01:10 PM
update problem in DataGrid's UpdateCommand method dawn ASP .Net 1 07-28-2003 02:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57