DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: LinkButton and textbox

  1. #1
    Join Date
    Oct 2005

    LinkButton and textbox

    Hi All,

    thanks for your help in advance

    i have a textbox and a linkbutton and need to link them together
    in other words need the linkbutton to know what i have put in the textbox s i click on it,
    first off it is in a repeater control
    each row has a linkbutton which text value gets dynamically assigned each time the page is loaded, the information in the textbox is entered by the user so is different each time

    My page load code is as follows:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           If Not IsPostBack Then
                Dim myConnection As SqlConnection
                Dim myCommand As SqlDataAdapter
                myConnection = New SqlConnection("server=spumbu\sqlexpress;" & "database=oss;Trusted_Connection=Yes")
                myCommand = New SqlDataAdapter("SELECT NAME, SKU, DESCRIPTION, SALEPRICE, LOCATION, SALEPRICEPER100G FROM Products1 where CATEGORY Like 'Lollies' Order by 'Name'", _
                Dim ds As DataSet = New DataSet()
                MyRepeater.DataSource = ds
            End If
    End Sub
    so by using the CType command i can get the website to understand what button is clicked and place it in a label or literal however i can not get the linkbutton to capture the text with a textbox on the same row, can anyone give me a so called 'Kick' in the right direction

    to get the label to display the text value of the linkbutton is as follows
      Protected Sub MyRepeater_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles MyRepeater.ItemCommand
            Label1.Text = "The " & CType(e.CommandSource, LinkButton).Text & "button has been clicked"
    End Sub
    oh yes you will need the linkbutton code too
    <asp:Linkbutton ID="btnFeature" runat="server" CommandName="Select" Text='<&#37;#DataBinder.Eval(Container.DataItem, "SKU") %>'>
    anyhelp is always appreciated

    thanks again in advance
    Last edited by Hack; 09-17-2009 at 07:19 AM. Reason: Added Code Tags

  2. #2
    Join Date
    Oct 2005

    sorry it is late here

    and my textbox code is as follows

    <asp:textbox ID = "Textbox1" runat="Server" size ="4"></asp:textbox>

    thanks again in advance

Similar Threads

  1. Replies: 0
    Last Post: 07-01-2009, 10:03 AM
  2. Replies: 0
    Last Post: 09-08-2003, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center