User-1838255255 posted
Hi Skyformat48,
According to your description and code, i make a sample through your needs, please check the following sample code:
Sample Code:
<asp:FormView ID="FormView1" runat="server" OnDataBound="FormView1_DataBound">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>ID:
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Name:
</td>
<td>
<%# Eval("Name") %>
</td>
</tr>
<tr>
<td>Description:
</td>
<td>
<%# Eval("Description") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Description",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "Works as a scientist in USA.");
FormView1.DataSource = dt;
FormView1.DataBind();
}
}
protected void FormView1_DataBound(object sender, EventArgs e)
{
Label Label4 = (Label)FormView1.FindControl("Label1");
string label4 = Label4.Text;
if (label4 == "1")
{
Label4.Style.Add("display", "none");
}
else
{
// do nothing
}
}
Result:
Best Regards,
Eric Du