Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 26th, 2007, 04:49 AM
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
  #2 (permalink)  
Old April 26th, 2007, 05:00 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

same problem for the update command

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04:58 PM
DetailView Control Showkkath ASP.NET 2.0 Professional 1 November 23rd, 2005 01:48 PM



All times are GMT -4. The time now is 12:38 AM.


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