Single-Value Data Binding on TextBox...

J

Julius Fenata

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top