#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jul 2010
    Posts
    138
    Rep Power
    13

    Asp.Net Listview is inserting blank data instead of text in the textboxes


    I've tried using <asp:Parameter>, <asp:FormParameter> and <asp:ControlParameter>, either the insert doesnt work at all(ControlParamater) or it inserts a completely blank row. I use vb.net for the codebehind page, but there's currently no codebehind for the listview, as most examples showed there was no need for it, everything could be done directly from asp.net Thanks for looking at this.

    ASP.net Code

    Code:
    <asp:ListView ID="ListView1" runat="server" DataSourceID="BGExpensesDB" >
                    <AlternatingItemTemplate>
                        <tr style="background-color: #FFFFFF;color: #284775;">
                            <td>
    
                            </td>                    
                            <td>
                                <asp:Label ID="RecIDLabel" runat="server" Text='<%# Eval("RecID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' />
                            </td>
                            <td>
                                <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
                            </td>
                            <td>
                                <asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
                            </td>
                            <td>
                                <asp:Label ID="DayMaintenanceLabel" runat="server" Text='<%# Eval("DayMaintenance") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactLabel" runat="server" Text='<%# Eval("FirstContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactPhoneLabel" runat="server" Text='<%# Eval("FirstContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactLabel" runat="server" Text='<%# Eval("SecondContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactPhoneLabel" runat="server" Text='<%# Eval("SecondContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactLabel" runat="server" Text='<%# Eval("FinalContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactPhoneLabel" runat="server" Text='<%# Eval("FinalContactPhone") %>' />
                            </td>
    
                            <td>
                                <asp:LoginView ID="ClericalView" runat="server">
                                    <RoleGroups>                    
                                        <asp:RoleGroup Roles="Clerical">
                                            <ContentTemplate>
                                                <asp:linkButton ID="btnEdit" CommandName="Edit" runat="server" Text="Edit" />                            
                                            </ContentTemplate>
                                        </asp:RoleGroup>
                                    </RoleGroups>
                                </asp:LoginView>                         
                            </td>
                        </tr>
                    </AlternatingItemTemplate>
                    <EditItemTemplate>
                        <tr style="background-color: #999999;padding:4px">
                            <td>
                                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                            </td>
                            <td>
                                <asp:Label ID="RecIDLabel1" runat="server" Text='<%# Eval("RecID") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="LocationTextBox" runat="server" Text='<%# Bind("Location") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="DayMaintenanceTextBox" runat="server" Text='<%# Bind("DayMaintenance") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="FirstContactTextBox" runat="server" Text='<%# Bind("FirstContact") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="FirstContactPhoneTextBox" runat="server" Text='<%# Bind("FirstContactPhone") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="SecondContactTextBox" runat="server" Text='<%# Bind("SecondContact") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="SecondContactPhoneTextBox" runat="server" Text='<%# Bind("SecondContactPhone") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="FinalContactTextBox" runat="server" Text='<%# Bind("FinalContact") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="FinalContactPhoneTextBox" runat="server" Text='<%# Bind("FinalContactPhone") %>' />
                            </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>
                        </table>
                    </EmptyDataTemplate>
                
                    <InsertItemTemplate>
                        <asp:LoginView ID="ClericalView" runat="server">
                            <RoleGroups>                    
                                <asp:RoleGroup Roles="Clerical">
                                    <ContentTemplate>
                                            <tr style="">
                                                <td>
                                                    <asp:linkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                                                    <asp:linkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                                                </td>
                                                <td>&nbsp;</td>
                                                <td>
                                                    <asp:TextBox ID="InsertLocationTextBox" runat="server" Text='<%# Bind("Location") %>' />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertAddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertCityTextBox" runat="server" Text='<%# Bind("City") %>' />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertDayMaintenanceTextBox" runat="server" Text='<%# Bind("DayMaintenance") %>' />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertFirstContactTextBox" runat="server" Text='<%# Bind("FirstContact") %>'/>
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertFirstContactPhoneTextBox" runat="server" Text='<%# Bind("FirstContactPhone") %>'/>
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertSecondContactTextBox" runat="server" Text='<%# Bind("SecondContact") %>'/>
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertSecondContactPhoneTextBox" runat="server" Text='<%# Bind("SecondContactPhone") %>'  />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertFinalContactTextBox" runat="server" Text='<%# Bind("FinalContact") %>' />
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="InsertFinalContactPhoneTextBox" runat="server" Text='<%# Bind("FinalContactPhone") %>' />
                                                </td>
                        
                                            </tr>                                
                                    </ContentTemplate>
                                </asp:RoleGroup>
                            </RoleGroups>
                        </asp:LoginView>
                    
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <tr style="background-color: #d3d3d3;color: #333333; ">
                            <td>
    
                            </td>
                            <td>
                                <asp:Label ID="RecIDLabel" runat="server" Text='<%# Eval("RecID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' />
                            </td>
                            <td>
                                <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
                            </td>
                            <td>
                                <asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
                            </td>
                            <td>
                                <asp:Label ID="DayMaintenanceLabel" runat="server" Text='<%# Eval("DayMaintenance") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactLabel" runat="server" Text='<%# Eval("FirstContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactPhoneLabel" runat="server" Text='<%# Eval("FirstContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactLabel" runat="server" Text='<%# Eval("SecondContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactPhoneLabel" runat="server" Text='<%# Eval("SecondContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactLabel" runat="server" Text='<%# Eval("FinalContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactPhoneLabel" runat="server" Text='<%# Eval("FinalContactPhone") %>' />
                            </td>
                            <td>
                                <asp:LoginView ID="ClericalView" runat="server">
                                    <RoleGroups>                    
                                        <asp:RoleGroup Roles="Clerical">
                                            <ContentTemplate>
                                                <asp:linkButton ID="btnEdit" CommandName="Edit" runat="server" Text="Edit" />                                                                   
                                            </ContentTemplate>
                                        </asp:RoleGroup>
                                    </RoleGroups>
                                </asp:LoginView>                         
                            </td>
                        </tr>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table runat="server">
                            <tr runat="server">
                                <td runat="server">
                                    <table id="itemPlaceholderContainer" runat="server" border="1" style="align-content:center; 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="align-content:center; background-color: #bfbfbf;color: #333333;">
                                            <th runat="server" ></th>
                                            <th runat="server" >RecID</th>
                                            <th runat="server">Location</th>
                                            <th runat="server">Address</th>
                                            <th runat="server">City</th>
                                            <th runat="server">Day Maintenance</th>
                                            <th runat="server">First Contact</th>
                                            <th runat="server">Phone</th>
                                            <th runat="server">Second Contact</th>
                                            <th runat="server">Phone</th>
                                            <th runat="server">Final Contact</th>
                                            <th runat="server">Phone</th>            
                                            <th runat="server"><asp:linkbutton ID="ShowInsert" runat="server" OnClick="ShowInsert_Click" Text="Insert" /></th>                                                                                                                                
                                        </tr>
                                        <tr id="itemPlaceholder" runat="server">                                    
                                        </tr>                                
                                    </table>
                                </td>
                            </tr>
                            <tr runat="server">
                                <td runat="server" style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF;"></td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                    <SelectedItemTemplate>
                        <tr style="background-color: #E2DED6;font-weight: bold;color: #333333;">
                            <td>
                                <asp:Label ID="RecIDLabel" runat="server" Text='<%# Eval("RecID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' />
                            </td>
                            <td>
                                <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
                            </td>
                            <td>
                                <asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
                            </td>
                            <td>
                                <asp:Label ID="DayMaintenanceLabel" runat="server" Text='<%# Eval("DayMaintenance") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactLabel" runat="server" Text='<%# Eval("FirstContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FirstContactPhoneLabel" runat="server" Text='<%# Eval("FirstContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactLabel" runat="server" Text='<%# Eval("SecondContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="SecondContactPhoneLabel" runat="server" Text='<%# Eval("SecondContactPhone") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactLabel" runat="server" Text='<%# Eval("FinalContact") %>' />
                            </td>
                            <td>
                                <asp:Label ID="FinalContactPhoneLabel" runat="server" Text='<%# Eval("FinalContactPhone") %>' />
                            </td>
                        </tr>
                    </SelectedItemTemplate>
                </asp:ListView>
                <asp:SqlDataSource 
                    ID="BGExpensesDB" 
                    runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BGDB %>" 
                    SelectCommand="SELECT * FROM [EmergencyContacts] ORDER BY [City]" 
                    InsertCommand="INSERT INTO [EmergencyContacts] (Location, Address, City, DayMaintenance, FirstContact, FirstContactPhone, SecondContact, SecondContactPhone, FinalContact, FinalContactPhone) VALUES (@Location, @Address, @City, @DayMaintenance, @FirstContact, @FirstContactPhone, @SecondContact, @SecondContactPhone, @FinalContact, @FinalContactPhone)">
                        <InsertParameters>                                                
                            <asp:Parameter Name="Location" Type="String"/>
                            <asp:Parameter Name="Address" Type="String"/>
                            <asp:Parameter Name="City" Type="String"/>
                            <asp:Parameter Name="DayMaintenance" Type="String"/>
                            <asp:Parameter Name="FirstContact" Type="String"/>
                            <asp:Parameter Name="FirstContactPhone" Type="String"/>
                            <asp:Parameter Name="SecondContact" Type="String"/>
                            <asp:Parameter Name="SecondContactPhone" Type="String"/>
                            <asp:Parameter Name="FinalContact" Type="String" />
                            <asp:Parameter Name="FinalContactPhone" Type="String" />
                        </InsertParameters>
                </asp:SqlDataSource>
    Last edited by Superdawg; August 4th, 2016 at 01:51 PM.

Similar Threads

  1. Help with inserting data into a fixed width text file
    By tks2512 in forum Windows Scripting
    Replies: 1
    Last Post: August 28th, 2008, 08:35 PM
  2. Help !!! blank data is inserting in db .......
    By silu95421 in forum ASP Development
    Replies: 2
    Last Post: October 12th, 2006, 09:19 AM
  3. Inserting Blank records
    By YoungAngus in forum ASP Development
    Replies: 18
    Last Post: October 4th, 2005, 06:29 AM
  4. Replies: 3
    Last Post: July 18th, 2005, 10:55 AM
  5. Inserting dynamic text box data into a database
    By dcampos in forum ASP Development
    Replies: 1
    Last Post: August 20th, 2004, 04:30 PM

IMN logo majestic logo threadwatch logo seochat tools logo