Hi Dave,
As for the ASP.NET webcontrols, they all support simple databinding without
using those template databinding control (such as FormView, GridView...).
So for your scenario, you can just declare a page variable(non-private) in
the page's code behind class which is of the dataobject type(contains the
data propertes you want to bound them to the controls on the page). Then,
in the page's aspx template, we can just databinding expression to bind the
data properties on the data object onto the controls in the page. e.g:
==========aspx=============
............................
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"></asp:SqlDataSource>
</div>
<asp:Label ID="Label1" runat="server"
Text="CategoryID:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
category.CategoryID %>'></asp:TextBox><br />
<asp:Label ID="Label2" runat="server"
Text="CategoryName:"></asp:Label><asp:TextBox
ID="TextBox2" runat="server" Text='<%# category.CategoryName
%>'></asp:TextBox><br />
<asp:Label ID="Label3" runat="server"
Text="Description:"></asp:Label><asp:TextBox
ID="TextBox3" runat="server" Text='<%# category.Description
%>'></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
===================
==========code behind========
public partial class _Default : System.Web.UI.Page
{
protected CategoryDS.CategoriesDataTable dt;
protected CategoryDS.CategoriesRow category;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CategoryDSTableAdapters.CategoriesTableAdapter ta = new
CategoryDSTableAdapters.CategoriesTableAdapter();
dt = ta.GetData();
category = dt.Rows[0] as CategoryDS.CategoriesRow;
Page.DataBind();
}
}
}
========================
# I call Page.DataBind so as to make all the databinding expression in the
page get evaluated (after I've populated the page member variable which
hold the dataobject for databinding).
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)