Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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
  #1 (permalink)  
Old March 23rd, 2016, 03:44 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update/delete using gridview

I believe I followed the MS instructions, but cannot seem to get the following code to work. When either the update or delete links are pressed, nothing happens. There is no code-behind except to obtain a username on page load. Here's the aspx code:
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LSOEdit.aspx.vb" Inherits="Secure_LSOEdit" %>

<!DOCTYPE html>
<link href="../CSS/Style1.css" rel="stylesheet" />
<link href="../CSS/style2.css" rel="stylesheet" />
<link href="../CSS/Style3.css" rel="stylesheet" />
<link href="../CSS/style4.css" rel="stylesheet" />
<link href="../CSS/style5.css" rel="stylesheet" />
<link href="../CSS/style6.css" rel="stylesheet" />
<link href="../CSS/style7.css" rel="stylesheet" />
<link href="../CSS/style8.css" rel="stylesheet" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            font-size: x-large;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <center>
        <br />
        <span class="auto-style1"><strong>Edit/Change LSO Activity 
        <br />
        </strong></span> <br />
        To find the entry to edit, please choose the following:<br />
        <br />
        Badge Number: <asp:DropDownList ID="ddlBadge" runat="server" AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="badgeno" DataValueField="badgeno"><asp:ListItem Selected="True"> </asp:ListItem></asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LSOActivityConnectionString %>" SelectCommand="SELECT distinct [badgeno] FROM [activity] ORDER BY [badgeno]"></asp:SqlDataSource>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required" ControlToValidate="ddlbadge" Display="Dynamic"></asp:RequiredFieldValidator>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Week Ending Date: <asp:DropDownList ID="ddlWkend" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="wkend" DataValueField="wkend"><asp:ListItem Selected="True"> </asp:ListItem></asp:DropDownList>
              <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Required" ControlToValidate="ddlWkend" Display="Dynamic"></asp:RequiredFieldValidator>
         <asp:SqlDataSource ID="SqlDataSourceDate" runat="server" ConnectionString="<%$ ConnectionStrings:LSOActivityConnectionString %>" SelectCommand="SELECT distinct [wkend] FROM [activity] WHERE ([badgeno] = @badgeno)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlBadge" Name="badgeno" PropertyName="SelectedValue" Type="Decimal" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LSOActivityConnectionString %>" SelectCommand="SELECT distinct (convert(varchar(10), wkend, 101)) as wkend FROM [activity] ORDER BY [wkend]"></asp:SqlDataSource>
        <br />
               <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" DataKeyNames="rptnum">
            <Columns>
                <asp:BoundField DataField="rptnum" HeaderText="rptnum" SortExpression="rptnum" ReadOnly="True" />
                <asp:BoundField DataField="date" HeaderText="date" SortExpression="date" DataFormatString="{0:d}" />
                <asp:BoundField DataField="vhnum" HeaderText="vhnum" SortExpression="vhnum" />
                <asp:BoundField DataField="sttime" HeaderText="sttime" SortExpression="sttime" />
                <asp:BoundField DataField="endtime" HeaderText="endtime" SortExpression="endtime" />
                <asp:BoundField DataField="location" HeaderText="location" SortExpression="location" />
                <asp:BoundField DataField="loccode" HeaderText="loccode" SortExpression="loccode" />
                <asp:BoundField DataField="detail" HeaderText="detail" SortExpression="detail" />
                <asp:BoundField DataField="miles" HeaderText="miles" SortExpression="miles" />
                <asp:BoundField DataField="certno" HeaderText="certno" SortExpression="certno" />
                <asp:BoundField DataField="head" HeaderText="head" SortExpression="head" />
                <asp:BoundField DataField="b" HeaderText="b" SortExpression="b" />
                <asp:BoundField DataField="c" HeaderText="c" SortExpression="c" />
                <asp:BoundField DataField="d" HeaderText="d" SortExpression="d" />
                <asp:BoundField DataField="e" HeaderText="e" SortExpression="e" />
                <asp:BoundField DataField="f" HeaderText="f" SortExpression="f" />
                <asp:BoundField DataField="drno" HeaderText="drno" SortExpression="drno" />
            </Columns>
        </asp:GridView>

        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:LSOActivityConnectionString %>" SelectCommand="SELECT [rptnum], [date], [vhnum], [sttime], [endtime], [location], [loccode], [detail], [miles], [certno], [head], [b], [c], [d], [e], [f], [drno] FROM [activity] WHERE (([badgeno] = @badgeno) AND ([wkend] = @wkend))" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [activity] WHERE [rptnum] = @original_rptnum"  UpdateCommand="UPDATE [activity] SET [date] = @date, [vhnum] = @vhnum, [sttime] = @sttime, [endtime] = @endtime, [location] = @location, [loccode] = @loccode, [detail] = @detail, [miles] = @miles, [certno] = @certno, [head] = @head, [b] = @b, [c] = @c, [d] = @d, [e] = @e, [f] = @f, [drno] = @drno WHERE [rptnum] = @original_rptnum AND [date] = @original_date AND (([vhnum] = @original_vhnum) OR ([vhnum] IS NULL AND @original_vhnum IS NULL)) AND [sttime] = @original_sttime AND [endtime] = @original_endtime AND [location] = @original_location AND (([loccode] = @original_loccode) OR ([loccode] IS NULL AND @original_loccode IS NULL)) AND (([detail] = @original_detail) OR ([detail] IS NULL AND @original_detail IS NULL)) AND [miles] = @original_miles AND (([certno] = @original_certno) OR ([certno] IS NULL AND @original_certno IS NULL)) AND (([head] = @original_head) OR ([head] IS NULL AND @original_head IS NULL)) AND (([b] = @original_b) OR ([b] IS NULL AND @original_b IS NULL)) AND (([c] = @original_c) OR ([c] IS NULL AND @original_c IS NULL)) AND (([d] = @original_d) OR ([d] IS NULL AND @original_d IS NULL)) AND (([e] = @original_e) OR ([e] IS NULL AND @original_e IS NULL)) AND (([f] = @original_f) OR ([f] IS NULL AND @original_f IS NULL)) AND (([drno] = @original_drno) OR ([drno] IS NULL AND @original_drno IS NULL))">
            
            <DeleteParameters>
                <asp:Parameter Name="original_rptnum" Type="String" />
<%--                <asp:Parameter DbType="Date" Name="original_date" />
                <asp:Parameter Name="original_vhnum" Type="String" />
                <asp:Parameter Name="original_sttime" Type="String" />
                <asp:Parameter Name="original_endtime" Type="String" />
                <asp:Parameter Name="original_location" Type="String" />
                <asp:Parameter Name="original_loccode" Type="String" />
                <asp:Parameter Name="original_detail" Type="String" />
                <asp:Parameter Name="original_miles" Type="Decimal" />
                <asp:Parameter Name="original_certno" Type="String" />
                <asp:Parameter Name="original_head" Type="Decimal" />
                <asp:Parameter Name="original_b" Type="String" />
                <asp:Parameter Name="original_c" Type="String" />
                <asp:Parameter Name="original_d" Type="String" />
                <asp:Parameter Name="original_e" Type="String" />
                <asp:Parameter Name="original_f" Type="String" />
                <asp:Parameter Name="original_drno" Type="String" />--%>
            </DeleteParameters>
                        <SelectParameters>
                <asp:ControlParameter ControlID="ddlBadge" Name="badgeno" PropertyName="SelectedValue" Type="Decimal" />
                <asp:ControlParameter ControlID="ddlWkend" DbType="Date" Name="wkend" PropertyName="SelectedValue" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter DbType="Date" Name="date" />
                <asp:Parameter Name="vhnum" Type="String" />
                <asp:Parameter Name="sttime" Type="String" />
                <asp:Parameter Name="endtime" Type="String" />
                <asp:Parameter Name="location" Type="String" />
                <asp:Parameter Name="loccode" Type="String" />
                <asp:Parameter Name="detail" Type="String" />
                <asp:Parameter Name="miles" Type="Decimal" />
                <asp:Parameter Name="certno" Type="String" />
                <asp:Parameter Name="head" Type="Decimal" />
                <asp:Parameter Name="b" Type="String" />
                <asp:Parameter Name="c" Type="String" />
                <asp:Parameter Name="d" Type="String" />
                <asp:Parameter Name="e" Type="String" />
                <asp:Parameter Name="f" Type="String" />
                <asp:Parameter Name="drno" Type="String" />
                <asp:Parameter Name="original_rptnum" Type="String" />
                <asp:Parameter DbType="Date" Name="original_date" />
                <asp:Parameter Name="original_vhnum" Type="String" />
                <asp:Parameter Name="original_sttime" Type="String" />
                <asp:Parameter Name="original_endtime" Type="String" />
                <asp:Parameter Name="original_location" Type="String" />
                <asp:Parameter Name="original_loccode" Type="String" />
                <asp:Parameter Name="original_detail" Type="String" />
                <asp:Parameter Name="original_miles" Type="Decimal" />
                <asp:Parameter Name="original_certno" Type="String" />
                <asp:Parameter Name="original_head" Type="Decimal" />
                <asp:Parameter Name="original_b" Type="String" />
                <asp:Parameter Name="original_c" Type="String" />
                <asp:Parameter Name="original_d" Type="String" />
                <asp:Parameter Name="original_e" Type="String" />
                <asp:Parameter Name="original_f" Type="String" />
                <asp:Parameter Name="original_drno" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>

    </center>
 
  
        <asp:Label ID="lblUser" runat="server" Visible="true"></asp:Label>
    </div>
    </form>
</body>
</html>
Thanks in advance


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to update database from GridView Edit/Update ssezotman BOOK: Beginning ASP.NET 4.5 : in C# and VB 1 January 23rd, 2015 06:16 PM
data gridview update, delete and insert to multi database khoonng BOOK: Beginning ASP.NET 4 : in C# and VB 1 December 13th, 2013 04:17 AM
Gridview Update not firing in Update Panel akshay144 Ajax 1 August 13th, 2009 10:20 AM
GridView Delete DARSIN ASP.NET 2.0 Basics 2 March 20th, 2007 06:53 AM
Insert, update, delete in gridview-!!! URGENT !!! dagad ASP.NET 2.0 Basics 0 September 27th, 2006 06:24 AM





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