This is a migrated thread and some comments may be shown as answers.

Initial Value CheckBox in Grid

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 24 Jan 2011, 07:36 PM
I have the following code and I always get invalid cast when going into insert.. how can I set in ititial value for a checkbox

<telerik:GridTemplateColumn HeaderText="Is Active" UniqueName="Is_Active">
   <EditItemTemplate>
       <asp:CheckBox id="cbIsActive" runat="server"  Checked='<%# Bind("Is_Active") %>' ></asp:CheckBox>
   </EditItemTemplate>
   <ItemStyle HorizontalAlign="Left" />
   <ItemTemplate> 
      <asp:Label ID="lbIsActive" runat="server" Text='<%# Eval("Is_Active", "{0}") %>' /> 
   </ItemTemplate> 
 </telerik:GridTemplateColumn>
 
 
and
  
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
      if (e.CommandName == RadGrid.InitInsertCommandName)
      {
         e.Canceled = true;
         System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
          newValues["Is_Active"] = false;
          e.Item.OwnerTableView.InsertItem();
      }
    }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jan 2011, 10:37 AM
Hello,


You could access the CheckBox control in ItemDataBound event (using FindControl method) of grid and set the initial state for the control.
Distinguish edit/insert mode on ItemCreated/ItemDataBound
findcontrol control in insert mode


-Shinu.
Tags
Grid
Asked by
Ken
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or