Hello,
I have a 'record update' feature enabled grid (2012 Q1).
I am using <FormTemplate> for editing/updating the data on the grid.
In the FormTemplate, I have a RadioButtonList named 'rdGrade' which is bound to the 'SchoolGrade' field in my database. The code for this RadioButtonList is as shown below.
<asp:RadioButtonList ID="rdGrade" runat="server"SelectedValue='<%# Bind("SchoolGrade") %>' DataSource='<%# (new string[] { "4", "5", "6" }) %>' AppendDataBoundItems="True"RepeatDirection="Horizontal"></asp:RadioButtonList>
Editing the SchoolGrade field with this RadioButtonList was fine. No errors.
But when I try to Add a new record by clicking the "+ Add new record" button, I get an error. So I had to add some extra code to the code behind page to set the default selected value of this RadioButtonList and the code I added was:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { //Add new" button clicked e.Canceled = true; //Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); newValues["SchoolGrade"] = 5; //Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); } }The code above sets the default selected value of the radio button list as 5.
My question is how do I change the code line
newValues["SchoolGrade"] = 5;
in order to initially UNCHECK the RadioButtonList rdGrade when a user clicks the 'Add new record' button on the grid?
Thank you.