View Single Post
  #1 (permalink)  
Old April 26th, 2007, 04:49 AM
tombert tombert is offline
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Detailview insert

Hi all,

I have a detailview control with a special template:
Code:
       <asp:TemplateField HeaderText="Name" >
               <ItemTemplate>
                    <asp:Label ID="lblCategoryName" runat="server" Text='<%# Eval("category_name") %>'></asp:Label>
               </ItemTemplate>
               <EditItemTemplate>
                    <asp:TextBox ID="txtCategoryName" runat="server" Text='<%# eval ("category_name") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator Display="Dynamic" ControlToValidate="txtCategoryName" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Category name is required">*</asp:RequiredFieldValidator>
               </EditItemTemplate>
               <InsertItemTemplate>

                     <asp:TextBox ID="txtCategoryName"   runat="server" ></asp:TextBox>
                    <asp:RequiredFieldValidator Display="Dynamic" ControlToValidate="txtCategoryName" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Category name is required">*</asp:RequiredFieldValidator>
               </InsertItemTemplate>
            </asp:TemplateField>


Datasource is a sqldatasource:

Code:
     <asp:SqlDataSource ID="DS_CategoryDetail" runat="server" ConnectionString="<%$ ConnectionStrings:Qwise_mgrConnectionString %>" 
            SelectCommand="SELECT [category_id], [category_name], isnull([parent],0) as parent_id, (select category_name from category where category_id= c.parent) as parent_name, [description] FROM [category] c WHERE ([category_id] = @category_id)"
             InsertCommand="INSERT into [category] ([category_name],[parent],[description]) values(@category_name, @parent, @description)"
             UpdateCommand=""
             DeleteCommand="update [category] set [deleted]=1 where category_id=@category_id">
            <SelectParameters>
                <asp:QueryStringParameter Name="category_id" QueryStringField="category_id" Type="String" />
            </SelectParameters>
            <InsertParameters>
                  <asp:ControlParameter ControlID="txtCategoryName" Name="category_name" Type="string" />
                  <asp:ControlParameter ControlID="lstParent" Name="parent" Type="string" />

                  <asp:ControlParameter ControlID="txtDescription" Name="category_txtDescription" Type="string" />

            </InsertParameters>
            <UpdateParameters>
            </UpdateParameters>
            <DeleteParameters>                
                <asp:QueryStringParameter Name="category_id" QueryStringField="category_id" Type="String" />
            </DeleteParameters>
        </asp:SqlDataSource>
when i try to insert a new category asp.net gives me an error:
"Could not find control 'txtCategoryName' in ControlParameter 'category_name'. "
but like you can see there is a control that is named txtCategoryName
what am i doing wrong? or what did i forgot?
Thanx!

Reply With Quote