<
telerik:RadNumericTextBox ID="txtThreshold" runat="server" Width="104px" Value='<%# DataBinder.Eval(Container,"DataItem.threshold") %>'></telerik:RadNumericTextBox>
This works fine for editing, but when I try to use it for inserting I always get an InvalidCastException: "The specified cast is invalid" with the folowing stack trace:
at ASP.configuration_alerts_aspx.__DataBinding__control24(Object sender, EventArgs e) in d:\Projects\WebMonitor\Web\Configuration\Alerts.aspx:line 77
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()
Replacing the NumericTextBox with a standard TextBox works fine. I have also tried setting a custom value in the ItemCommand event, to really make sure there is a value being passed to the control:
protected
void gridAlertTypes_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled = true;
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();newValues["description"] = "New description";
newValues["threshold"] = 55;
e.Item.OwnerTableView.InsertItem(newValues);
}
}
But I still get the same error. I have also tried to declare the control so that the DataBinding only happens when in edit mode, and for insert I declare a hard-coded value of 0:
<telerik:RadNumericTextBox ID="txtThreshold" runat="server" Width="104px" Value='<%# (Container is GridEditFormInsertItem) ? 0 : DataBinder.Eval(Container,"DataItem.threshold") %>'></telerik:RadNumericTextBox>
But still no luck! I tried putting double quotes around the 0 as well. Which is strange, because if I use Value='0' that works fine, effectivly thats what the above statement should do when in insert mode. Any help would be appreciated!
Thanks
Michael