Single-Value Data Binding on TextBox...

Discussion in 'ASP .Net Web Controls' started by Julius Fenata, Mar 3, 2005.

  1. Dear all,

    Need help to bind single-value on textbox.., I have code on code-behind like
    this...

    private void Page_Load(object sender, System.EventArgs e)
    {
    if ( ! Page.IsPostBack )
    {
    BindData();
    this.DataBind();
    }
    }

    private void BindData()
    {
    // Connection
    SqlConnection cn_Pubs =
    new SqlConnection("server=(local);" +
    "uid=sa;" +
    "pwd=;" +
    "database=pubs");

    // Adapter
    SqlDataAdapter da_Titles =
    new SqlDataAdapter("SELECT title, " +
    "notes, " +
    "price " +
    "FROM titles", cn_Pubs);

    // DataSet
    DataSet ds_Titles = new DataSet();
    da_Titles.Fill(ds_Titles, "titles");
    }

    And have coded in Web Forms like this...

    <asp:TextBox
    id=TextBox1
    runat="server"
    Text='<%# DataBinder.Eval(ds_Titles, "title") %>'>
    </asp:TextBox>

    But Compiler throw error message like this...

    CS0103: The name 'ds_Titles' does not exist in the class or namespace
    'ASP.WebForm1_aspx'


    How to resolve this problem..?

    Thx,
    Julius F
     
    Julius Fenata, Mar 3, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordan
    Replies:
    2
    Views:
    2,539
    Jordan
    Feb 10, 2004
  2. Ali M
    Replies:
    2
    Views:
    6,720
    Ali M
    Feb 15, 2005
  3. JcFx
    Replies:
    0
    Views:
    281
  4. Flyguy
    Replies:
    1
    Views:
    950
    Walter Wang [MSFT]
    Jan 2, 2007
  5. Vivek Nallur

    value binding and function binding

    Vivek Nallur, Sep 25, 2003, in forum: Ruby
    Replies:
    0
    Views:
    138
    Vivek Nallur
    Sep 25, 2003
Loading...

Share This Page