Home > DeveloperSection > Forums > How to Disable/Enable input-box in aspx with value from SQL
Goti Bandu

Total Post:119

Points:835
Posted on    January-26-2015 10:47 PM

 ASP.Net HTML  Input Validation 
Ratings:


 1 Reply(s)
 539  View(s)
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.



Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    January-27-2015 12:15 AM

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

 

            }

        }


Don't want to miss updates? Please click the below button!

Follow MindStick