Well, I have an EditTemplate that I bound some data to some RadControl. The problem is when I try to insert, I got errors on bound item because they are DBnull. So how can I have the template with empty control while inserting?
Jocelyn
Jocelyn
4 Answers, 1 is accepted
0
Elliott
Top achievements
Rank 2
answered on 05 Mar 2012, 10:48 PM
for starters, remove any DataType parameters
on numeric text boxes, change the Value= to DBValue=
on numeric text boxes, change the Value= to DBValue=
0
Jocelyn
Top achievements
Rank 1
answered on 06 Mar 2012, 02:40 PM
Thanks Marianne.
I already use DbValue. I got this error on non-rad controls like Checkbox.
What can I do to solve this?
I already use DbValue. I got this error on non-rad controls like Checkbox.
What can I do to solve this?
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Mar 2012, 07:42 AM
Hello Jocelyn,
The reason for this error is that your grid instance can not bind a value for the newly inserted item through the Eval()/Bind() syntax. A solution would be to preset the default value of the control(s) when binding to a grid item on the RadGrid.InitInsertCommandName command.
ASPX:
C#:
Hope this helps,
Princy.
The reason for this error is that your grid instance can not bind a value for the newly inserted item through the Eval()/Bind() syntax. A solution would be to preset the default value of the control(s) when binding to a grid item on the RadGrid.InitInsertCommandName command.
ASPX:
telerik:GridTemplateColumn HeaderText="" UniqueName="StartCheckboxColumn" > <ItemTemplate> <asp:CheckBox ID="StartCheckbox" runat="server" AutoPostBack="true" Checked='<%# Bind("START") %>' /> </ItemTemplate> </telerik:GridTemplateColumn>C#:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if ((e.CommandName == RadGrid.InitInsertCommandName)) { e.Canceled = true; //Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); //set initial checked state for the checkbox on init insert newValues("START") = false; //Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); } }Hope this helps,
Princy.
0
Jocelyn
Top achievements
Rank 1
answered on 07 Mar 2012, 04:29 PM
Thanks ! It works!