Link to home
Start Free TrialLog in
Avatar of samme
sammeFlag for United States of America

asked on

place textbox text into another textbox when button clicked in repeater

I am populating textbox2 with data from the database what i would like to try and do is populate textbox1 with text from textbox2 when button1 is clicked.  This is what i have so far. I am not exactly sure the vb code should be. So the question is what should the vb code be?


<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2">
       <ItemTemplate>
               <%-- <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br /><br />--%>
               <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
               <asp:TextBox ID="TextBox2" runat="server" text='<%# Eval("ShipCity") %>'></asp:TextBox><br />
               <asp:Button ID="Button1" runat="server" Text="edit" OnClick="Update" />
        </ItemTemplate>
</asp:Repeater>

ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samme

ASKER

2 errors show up

Ctype(e.Item.FindControl("TextBox1"),TextBox) <---end of statement expected error
txtTemp.Text<---txtTemp not declared error
Avatar of samme

ASKER

Corrected like this: I had to take the new out

Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
        If (e.CommandName = "Update") Then
            Dim TextFromTextBox2 As String = CType(e.Item.FindControl("textbox2"), TextBox).Text
            Dim txtTemp As TextBox = CType(e.Item.FindControl("textbox1"), TextBox)
            txtTemp.Text = TextFromTextBox2
        End If

    End Sub
Sorry Samme,
I was too tired to see anything when I answered your question.
Glad you got it fixed

Good luck

Sammy