Can not Edit gridview having TemplateField

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolcoder2007
    New Member
    • Nov 2007
    • 3

    Can not Edit gridview having TemplateField

    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 ControlParamete r 'Primary_Skill' ."I am giving the code below..Plz help me...

    <asp:GridView id="gdSkills" runat="server" DataSourceID="S qlDataSource1" DataKeyNames="E mp_code,Skill_I d" PageSize="15" AllowPaging="Tr ue" AutoGenerateCol umns="False">
    <HeaderStyle CssClass="gridV iewHeader" />
    <RowStyle CssClass="gridV iewRowStyle" Wrap="False" Width="100%" />
    <AlternatingRow Style CssClass="gridV iewAlternative" Wrap="False" Width="100%" />
    <Columns>
    <asp:BoundFie ld DataField="Skil l_name" HeaderText="Ski ll" ReadOnly="True" />
    <asp:BoundFie ld DataField="No_M onths" HeaderText="No of Months" />
    <asp:TemplateFi eld HeaderText="Pri mary">
    <ItemTemplate >
    <asp:CheckBox ID="chkPrimary " runat="server" Checked='<%# GetBoolean(Eval ("Skill_Id"),Ev al("Emp_code")) %>' />
    </ItemTemplate>
    </asp:TemplateFie ld>
    <asp:CommandFie ld ShowEditButton= "True"/>
    </Columns>
    </asp:GridView>
    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ProviderName="S ystem.Data.SqlC lient"

    ConnectionStrin g="<%$ ConnectionStrin gs:MyDatabase%> "


    SelectCommand=" select ES.Skill_id,Ski ll_name,emp_cod e,No_Months,Pri mary_Skill from Skill S
    join Emp_skills ES on S.Skill_id=ES.S kill_id
    where emp_code=@Emp_c ode order by Skill_name"
    UpdateCommand=" update emp_Skills set No_Months=@No_M onths,Primary_S kill=@Primary_S kill where Skill_id=@Skill _id AND EMP_CODE=@Emp_C ode">
    <SelectParamete rs>
    <asp:SessionPar ameter Name="Emp_code" SessionField="E mpcode" Type="String" />
    </SelectParameter s>
    <UpdateParamete rs>
    <asp:Paramete r Name="No_Months " Type="Double" />
    <asp:Paramete r Name="Skill_id" Type="Int32" />
    <asp:ControlPar ameter Name="Primary_S kill" ControlID="chkP rimary" />
    <asp:SessionPar ameter Name="Emp_code" SessionField="E mpcode" Type="String" />
    </UpdateParameter s>
    </asp:SqlDataSour ce>
Working...