Can not Edit gridview having TemplateField

Mar 5 2008 3:15 AM
 Hi,

I have a gridview which is having a TemplateField with a checkbox.When I edit this field an erro is occured saying,"Could not find control 'chkPrimary' in ControlParameter 'Primary_Skill'."I am giving the code below..Plz help me...

<asp:GridView id="gdSkills" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="Emp_code,Skill_Id" PageSize="15" AllowPaging="True" AutoGenerateColumns="False">
        <HeaderStyle CssClass="gridViewHeader" />
        <RowStyle CssClass="gridViewRowStyle" Wrap="False" Width="100%"  />
        <AlternatingRowStyle CssClass="gridViewAlternative" Wrap="False" Width="100%" />
                 <Columns>
                  <asp:BoundField DataField="Skill_name" HeaderText="Skill" ReadOnly="True" />
                  <asp:BoundField DataField="No_Months" HeaderText="No of Months" />
                   <asp:TemplateField HeaderText="Primary">
                     <ItemTemplate>
                         <asp:CheckBox ID="chkPrimary" runat="server" Checked='<%# GetBoolean(Eval("Skill_Id"),Eval("Emp_code"))%>' />
                      </ItemTemplate>
                   </asp:TemplateField>
                   <asp:CommandField ShowEditButton= "True"/>
                   </Columns>
         </asp:GridView>
         <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ProviderName="System.Data.SqlClient"

                ConnectionString="<%$ ConnectionStrings:MyDatabase%>"

             
                SelectCommand="select ES.Skill_id,Skill_name,emp_code,No_Months,Primary_Skill from Skill S
                               join Emp_skills ES on S.Skill_id=ES.Skill_id
                               where emp_code=@Emp_code order by Skill_name"
                UpdateCommand="update emp_Skills set No_Months=@No_Months,Primary_Skill=@Primary_Skill where Skill_id=@Skill_id AND EMP_CODE=@Emp_Code">
                  <SelectParameters>
                   <asp:SessionParameter Name="Emp_code" SessionField="Empcode" Type="String" />
                  </SelectParameters>               
                  <UpdateParameters>
                      <asp:Parameter Name="No_Months" Type="Double" />
                      <asp:Parameter Name="Skill_id" Type="Int32" />
                      <asp:ControlParameter Name="Primary_Skill" ControlID="chkPrimary" />
                      <asp:SessionParameter Name="Emp_code" SessionField="Empcode" Type="String" />
                  </UpdateParameters>                 
         </asp:SqlDataSource>