Click here to Skip to main content
15,125,547 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a listview whose data is populated from database , everything works fine ,but while inserting a record if i press enter in the textbox(where value is inserted), the top row of listview is automatically deleted.....
here is my source code...

ASP.NET
<asp:ListView ID="ListView3" runat="server" DataKeyNames="furniture_id" 
                        DataSourceID="SqlDataSource1" InsertItemPosition="LastItem" 
                        style="text-align: center"> 
                        <edititemtemplate>
                            <tr style="background-color: #FFCC66;color: #000080;">                             
                                <td>
                                    <asp:TextBox ID="quantityTextBox" runat="server" 
                                        Text='<%# Bind("quantity") %>' />
                                </td>
                                <td>
                                    <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                                </td>
                                 <td>
                                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                                        Text="Update" />
                                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                                        Text="Cancel" />
                                </td>
                            </tr>
                        </edititemtemplate>
                        <emptydatatemplate>
                            <table  runat="server" 
                                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                                <tr>
                                    <td>
                                        No data was returned.</td>
                                </tr>
                            
                        </emptydatatemplate>
                        <insertitemtemplate>
                            <tr style="">
                               
                                
                                <td>
                                    <asp:TextBox ID="quantityTextBox" runat="server" 
                                        Text='<%# Bind("quantity") %>' />
                                </td>
                                <td>
                                    <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                                </td>
                                 <td>
                                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                                        Text="Insert" />
                                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                                        Text="Clear" />
                                </td>
                            </tr>
                        </insertitemtemplate>
                        <itemtemplate>
                            <tr style="background-color: #FFFBD6;color: #333333;">                                
                                <td>
                                    <asp:Label ID="quantityLabel" runat="server" Text='<%# Eval("quantity") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                                        Text="Delete" />
                                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                                </td>
                            </tr>
                        </itemtemplate>
                        <layouttemplate>
                            <table  runat="server">
                                <tr  runat="server">
                                    <td  runat="server">
                                        <table ID="itemPlaceholderContainer"  runat="server" border="1" 
                                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                                            <tr  runat="server" style="background-color: #FFFBD6;color: #333333;">
                                                
                                                <th  runat="server">
                                                    quantity
                                                <th  runat="server">
                                                    item name
                                                <th id="Th1"  runat="server">
                                                
                                            
                                            <tr ID="itemPlaceholder"  runat="server">
                                            
                                        
                                    
                                
                                <tr  runat="server">
                                    <td  runat="server" 
                                        style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
                                    
                                
                            
                        </layouttemplate>                       
Posted
Updated 7-Aug-12 21:29pm
v3
Comments
   
Can you post your inserting code and listview binding code..
Kenneth Haugland 8-Aug-12 2:20am
   
Please update you question with the relevant code. Push the Improve question button and paste it in :)
   
There are many different ways to screw up things. Which one did you use in your code?.. :-)
--SA

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