Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am using Detail view to insert details to the database.
First time i am using detail view,while running Detail view control is not visible.
Could you please help where i am going wrong.

ASP.NET
<tag>
 <asp:DetailsView ID="DetailsView1" runat="Server" CellPadding="4" 
                    ForeColor="#333333" GridLines="None"
     Width="100%" DataSourceID="SqlDataSource1" AllowPaging="False" AutoGenerateRows="False" DataKeyNames="DoNo"
     AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
                    AutoGenerateInsertButton="True" DefaultMode="Edit" Visible="True" >
        <footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
        <commandrowstyle backcolor="#E2DED6" font-bold="True" />
        <editrowstyle backcolor="#999999" />
        <rowstyle backcolor="#F7F6F3" forecolor="#333333" />
        <pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center" />
        <fieldheaderstyle backcolor="#E9ECF1" font-bold="True" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <alternatingrowstyle backcolor="White" forecolor="#284775" />
        <fields>
            <asp:TemplateField HeaderText="DoNo">
                <itemtemplate>
                    <%# Eval("DoNo") %>
                </itemtemplate>
            
            <asp:BoundField DataField="CompanyName" HeaderText="Company" />
            <asp:BoundField DataField="CompanyAddress" HeaderText="Address" />
            <asp:BoundField DataField="Tel" HeaderText="Tel" />
            <asp:BoundField DataField="Fax" HeaderText="Fax" />
            <asp:BoundField DataField="ContactPerson" HeaderText="Contact" />
            <asp:BoundField DataField="SalesPerson" HeaderText="SalesPerson" />    
        </fields>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database2.mdf;Integrated Security=True;User Instance=True'
     SelectCommand="Select * FROM DeliveryOrder ORDER BY [DoNo]"
     DeleteCommand="Delete FROM DeliveryOrder WHERE DoNo= @DoNo"
     UpdateCommand="UPDATE DeliveryOrder SET CompanyName = @CompanyName, CompanyAddress = @CompanyAddress, Tel = @Tel, Fax = @Fax, ContactPerson=@ContactPerson, SalesPerson=@SalesPerson WHERE DoNo = @DoNo"     
                    InsertCommand="INSERT INTO SampleForTutorials (CompanyName, CompanyAddress,Tel,Fax,ContactPerson,SalesPerson) VALUES (@CompanyName, @CompanyAddress,@Tel,@Fax,@ContactPerson,@SalesPerson)" 
                    ProviderName="System.Data.SqlClient">
        <deleteparameters>
            <asp:Parameter Name="DoNo" />
        </deleteparameters>
        <updateparameters>
            <asp:Parameter Name="DoNo" Type="Int32" />
            <asp:Parameter Name="CompanyName" Type="string" Size="50" />
            <asp:Parameter Name="CompanyAddress" Type="string" Size="200" />
            <asp:Parameter Name="Tel"  Type="Int32" />
            <asp:Parameter Name="Fax" Type="Int32" />
           <asp:Parameter Name="ContactPerson" Type="string" Size="20" />
           <asp:Parameter Name="SalesPerson" Type="string" Size="20" />
        </updateparameters>
        <insertparameters>
            <asp:Parameter Name="CompanyName" Type="string" Size="50" />
            <asp:Parameter Name="CompanyAddress" Type="string" Size="200" />
           <asp:Parameter Name="Tel"  Type="Int32" />
            <asp:Parameter Name="Fax" Type="Int32" />
           <asp:Parameter Name="ContactPerson" Type="string" Size="20" />
           <asp:Parameter Name="SalesPerson" Type="string" Size="20" />
        </insertparameters>
      
</tag>


Thanks.

Regards
Lancy
Posted
Updated 30-Oct-11 20:43pm
v2

1 solution

It might work, if you try
JavaScript
runat="server"
in all <asp:.. xmlns:asp="#unknown"> controls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900