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
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