How to Disable/Enable input-box in aspx with value from SQL

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

    <asp:Repeater ID="myList" runat="server" EnableViewState="true">
                <input type="text" disabled="<%# bool.Parse(Eval("Value1").ToString()) == true ? : "disabled" %>" />
                <input type="text" disabled="<%# bool.Parse(Eval("Value2").ToString()) == true ? : "disabled" %>" />

It's the

"disabled="<%# bool.Parse(Eval("Value1").ToString()) == true ? : "disabled" %>"

I would like help with.

Last updated:1/27/2015 12:15:33 AM

1 Answers

Anonymous User
Anonymous User

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());