Answered by:
Databinding

Question
-
User1453549677 posted
Why doesn't the databinding render? Thanks.
<body>
<form id="form1" runat="server">
<div>
<p>This is the count<%# Test%></p>
<p>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></p>
</div>
</form>
</body>
++++++++++++++++++++++++++++++++++++++
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int Test = 4;
}
}Friday, February 4, 2011 9:37 AM
Answers
-
User-1995538749 posted
Check out this example:
ASPX
<%@ page language="C#" masterpagefile="~/MasterPages/Default.master" autoeventwireup="true" codefile="CallAMethodInline.aspx.cs" inherits="HowTo_CallAMethodInline" title="Untitled Page" %> <asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server"> <div> Static Method: <%= MathHelper.Add(2, 2) %> </div> <div> Protected Method: <%= Add(2, 2) %> </div> <div> Protected Property: <%= Result %> </div> </asp:content>
CODE-BEHIND
using System; public partial class HowTo_CallAMethodInline : System.Web.UI.Page { protected int Result = 4; protected void Page_Load(object sender, EventArgs e) { } protected int Add(int x, int y) { return x + y; } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 4, 2011 9:47 AM
All replies
-
User-1995538749 posted
Check out this example:
ASPX
<%@ page language="C#" masterpagefile="~/MasterPages/Default.master" autoeventwireup="true" codefile="CallAMethodInline.aspx.cs" inherits="HowTo_CallAMethodInline" title="Untitled Page" %> <asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server"> <div> Static Method: <%= MathHelper.Add(2, 2) %> </div> <div> Protected Method: <%= Add(2, 2) %> </div> <div> Protected Property: <%= Result %> </div> </asp:content>
CODE-BEHIND
using System; public partial class HowTo_CallAMethodInline : System.Web.UI.Page { protected int Result = 4; protected void Page_Load(object sender, EventArgs e) { } protected int Add(int x, int y) { return x + y; } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 4, 2011 9:47 AM -
User1453549677 posted
Thanks.
Friday, February 4, 2011 2:39 PM -
User-928758068 posted
public partial class Default2 : System.Web.UI.Page
{protected int Test = 4;
protected void Page_Load(object sender, EventArgs e)
{this.DataBind();// this will bind your Test variable
}
}Friday, February 4, 2011 3:33 PM -
User-691245060 posted
this article would be of great help for you -
http://www.maconstateit.net/tutorials/ASPNET1/ASPNET07/aspnet07-01.aspx
Thanks.
Friday, February 4, 2011 9:07 PM