Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataBinding a textbox

Status
Not open for further replies.

ninelgorb

Programmer
Mar 7, 2005
111
0
0
US
I know how to bind data to a dropdown, but how can I bind to a textbox when it doesn't have the datasource property?

This is what I havae so far:
Code:
Private Sub ddlEmployee_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlEmployee.SelectedIndexChanged

        sAgentId = ddlEmployee.SelectedValue
        If sAgentId = "0" Then
            lblResult.Text = "Please Select an Employee"
        Else
            Call PopulateDDLs(sAgentId)
        End If
End Sub

Sub PopulateDDLs(ByVal sAgentId As String)
sSQLPayRollId = " SELECT iPayrollid FROM dbo.EmEmployee WHERE sAgentid= "" & ddlEmployee.SelectedValue & """
        sConn = System.Configuration.ConfigurationSettings.AppSettings.Item("connString")
        oConn = New SqlConnection(sConn)
        oConn.Open()
        oComm = New SqlCommand(sSQLReport, oConn)
        oReader = oComm.ExecuteReader()
       ????--- txtPayId.datasource = oReader ---??????
End Sub

Based on user's selection from dropdown I need to populate the textbox.

Any help would be greatly appreciated.
Thanks,
Ninel
 
A textbox has a databindings property which you have to set in the properties window.
 
When I use this property within the code I get a squiggly line underneath and it says 'DataBindings is not a member of 'System.Web.UI.WebControls.Textbox'.
Does this mean the only way I can use this property is within the property window?
 
I am looking at the property window and I don't understand how to use the databindings property.
Can you please help me out?

Thanks,
Ninel
 
Click on the elipsis.. the "..." button in box next to databindings. A popup window comes up with bindabale properties. Text is chooen by default. Then in the right pane, drill down to the object(column) you want to bind to.
 
On the right side I only see simple binding or custm binding radio buttons. Inside the simple binding I see unbound and page. That's it.

Am I missing something?
 
You should see any datasets, dataviews etc. that have been created on the design portion of your page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top