HOW TO DISABLE/ENABLE INPUT-BOX IN ASPX WITH VALUE FROM SQL

Goti Bandu

Total Post:119

Points:835
Posted by  Goti Bandu
 816  View(s)
Ratings:
Rate this:

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.

  1. Jeet Verma

    Post:110

    Points:776
    Re: How to Disable/Enable input-box in aspx with value from SQL

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

     

                }

            }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!