Once again I cannot find what I want on SO, so:
I want to disable input boxes in a repeater reading values from my MS-SQL if the value is False.
Code snippet
<tbody>
<asp:Repeater ID="myList" runat="server" EnableViewState="true">
<ItemTemplate>
<tr>
<td>
<input type="text" disabled="<%# bool.Parse(Eval("Value1").ToString()) == true ? : "disabled" %>" />
</td>
<td>
<input type="text" disabled="<%# bool.Parse(Eval("Value2").ToString()) == true ? : "disabled" %>" />
</td>
It's the
"disabled="<%# bool.Parse(Eval("Value1").ToString()) == true ? : "disabled" %>"
I would like help with.
Thank you Kruni Patil. Here is what I did:
protected void myList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = (DataRowView)e.Item.DataItem;
TextBox txtBoxM = (TextBox)e.Item.FindControl("TextBox1");
TextBox txtBoxT = (TextBox)e.Item.FindControl("TextBox2");
txtBoxM.Enabled = bool.Parse(row["Value1"].ToString());
txtBoxT.Enabled = bool.Parse(row["Valu2"].ToString());
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments