devpro
June 19th, 2001, 01:28 PM
Dear all,
I started with ASP.NET a few weeks ago, but just yesterday with ADO.NET. I
already have a problem. I know how to bind a DataGrid to a data source.
[in ASPX Page]
[in code behind page]
....
....
public void Page_Load(Object Source, EventArgs E)
{
if (!Page.IsPostBack)
{
ADODataSetCommand cmd = new ADODataSetCommand(strCmd, strConn);
Dataset ds = new DataSet();
cmd.FillDataSet(ds, "EmployeeList");
grid1.DataSource = ds.Tables["EmployeeList"].DefaultView;
}
Page.DataBind();
}
So far everything is OK. I now need to bind a TextBox to a single value, and
I don't know how to do this.
1) How can I get the value of a specific record and of a specific column?
2) How can I bind this value to the TextBox? I tried to get the value and
then do something like
<asp:TextBox runat="server" id="text1" text=
but it does not work, because the variable and all the DB logic is contained
in the CodeBehind CS file.
I think this are 2 simple questions, but if anyone will help, I will be
really grateful.
- Gianni
- devpro
I started with ASP.NET a few weeks ago, but just yesterday with ADO.NET. I
already have a problem. I know how to bind a DataGrid to a data source.
[in ASPX Page]
[in code behind page]
....
....
public void Page_Load(Object Source, EventArgs E)
{
if (!Page.IsPostBack)
{
ADODataSetCommand cmd = new ADODataSetCommand(strCmd, strConn);
Dataset ds = new DataSet();
cmd.FillDataSet(ds, "EmployeeList");
grid1.DataSource = ds.Tables["EmployeeList"].DefaultView;
}
Page.DataBind();
}
So far everything is OK. I now need to bind a TextBox to a single value, and
I don't know how to do this.
1) How can I get the value of a specific record and of a specific column?
2) How can I bind this value to the TextBox? I tried to get the value and
then do something like
<asp:TextBox runat="server" id="text1" text=
but it does not work, because the variable and all the DB logic is contained
in the CodeBehind CS file.
I think this are 2 simple questions, but if anyone will help, I will be
really grateful.
- Gianni
- devpro