Solved

place textbox text into another textbox when button clicked in repeater

Posted on 2006-11-02
4
380 Views
Last Modified: 2008-02-01
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>

0
Comment
Question by:samme
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 250 total points
ID: 17864324
Try this

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2" OnItemCommand="repeater1_ItemCommand">
       <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" CommandName="Update" />
        </ItemTemplate>
</asp:Repeater>
Private Sub repeater1_ItemCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs)
        If (e.CommandName = "Updade") Then
            Dim TextFromTextBox2 As String = CType(e.Item.FindControl("TextBox2"),TextBox).Text
           Dim txtTemp as new TextBox= Ctype(e.Item.FindControl("TextBox1"),TextBox)
                  txtTemp.Text=TextFromTextBox2
        End If
    End Sub

Here we use the ItemCommand event of the data repeater and the CommandName property of the button to get the text
0
 
LVL 1

Author Comment

by:samme
ID: 17866407
2 errors show up

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

Author Comment

by:samme
ID: 17866523
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
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17868755
Sorry Samme,
I was too tired to see anything when I answered your question.
Glad you got it fixed

Good luck

Sammy
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Footer for each row on Gridview 2 42
asp.net input html code have it display the content 2 32
Add a Condition in ASP Repeater 6 48
Change to file doesn't show up 16 80
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question