p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Detailview insert (http://p2p.wrox.com/showthread.php?t=57134)

tombert April 26th, 2007 04:49 AM

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!


tombert April 26th, 2007 05:00 AM

same problem for the update command



All times are GMT -4. The time now is 07:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.