Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 04:49 AM
Registered User
 
Join Date: Mar 2007
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!

 
Old April 26th, 2007, 05:00 AM
Registered User
 
Join Date: Mar 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

same problem for the update command






Similar Threads
Thread Thread Starter Forum Replies Last Post
Detailview with Checkbox kcsathish ASP.NET 1.0 and 1.1 Basics 1 July 10th, 2008 03:20 PM
Editing in DetailView using objectdatasourse balesh.mind ASP.NET 2.0 Professional 0 May 22nd, 2008 02:12 AM
Linking GridView to DetailView BOS ASP.NET 1.0 and 1.1 Basics 0 July 7th, 2007 12:40 AM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM
DetailView Control Showkkath ASP.NET 2.0 Professional 1 November 23rd, 2005 02:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.