I’m not very experienced in ASP.Net, as I work mostly with PHP. I’m trying this, but it doesn’t work:
<asp:TextBox runat='server' ID='txtAnswer' TextMode='<%# IIf(DataBinder.Eval(Container.DataItem, 'DoLargeInput'), 'MultiLine', 'SingleLine' )%>' Text=''></asp:TextBox>
DoLargeInput is a boolean.
Why doesn’t this work?
I’m gettin the following error:
System.InvalidCastException: Conversion from string 'MultiLine' to type 'Integer' is not valid. ---> System.FormatException: Input string was not in a correct format. at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) --- End of inner exception stack trace --- at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value) at ASP.profile_questions_aspx.__DataBinding__control6(Object sender, EventArgs e) at System.Web.UI.Control.OnDataBinding(EventArgs e) at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.Control.DataBindChildren() at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.Repeater.DataBind() at profile_questions.LoadObjects()
Any help would be greatly appreciated. Thanks!
Try:-
It the parse that will convert TextMode=’MultiLine’ approriately for you. At the point this binding code happens the parseing is over, you need to specify the value as you would in code.