I'm hoping someone can help me get data from a GridView into another GridView I made inside it. I'm trying to get the wo_id field from the first GridView into the second GridView's datasource (created inside the first).
Right now, in the code below, I have "tasks = tasks" in the WHERE clause of the "partsused" SqlDataSource, and I want it to use the wo_id field from the parent GridView instead (thus showing the correct list of parts for the specific work order).
<%# Page Language="VB" MaintainScrollPositionOnPostback="true" MasterPageFile="~/Main.master"
AutoEventWireup="false" CodeFile="WorkOrders.aspx.vb" Inherits="PendingWO" Title="Standard Work Orders" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<center>
<h3>
Standard Work Orders</h3>
<asp:LinkButton ID="lbPrintVersion" runat="server">View Printable Version</asp:LinkButton><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="wo_id"
DataSourceID="workOrders" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical" EmptyDataText="No records"
PageSize="5">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField SortExpression="wo_id" HeaderText="Work Order">
<ItemTemplate>
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" /><br />
<asp:ImageButton ID="btnHours" runat="server" ImageUrl="~/App_Themes/Images/hoursClock.png"
Height="40px" Width="40px" ToolTip="Hours" CommandName="Hours" />
<asp:ImageButton ID="btnParts" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/parts.png"
Width="40px" ToolTip="Parts Used" CommandName="Parts" />
<asp:HiddenField ID="hfColor" runat="server" Value='<%# Eval("machine_status_color") %>' />
</ItemTemplate>
<EditItemTemplate>
session("workorderid") = '<%# Eval("wo_id") %>'
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:GridView ID="GridView1" runat="server" DataSourceID="partsUsed" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" DataKeyNames="parts_used_id">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:BoundField DataField="parts_used_id" HeaderText="parts_used_id" InsertVisible="False"
ReadOnly="True" SortExpression="parts_used_id" Visible="False" />
<asp:BoundField DataField="tasks" HeaderText="Work Order" ReadOnly="True"
SortExpression="tasks" />
<asp:TemplateField HeaderText="Part" SortExpression="Part">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="partsList" DataTextField="Part"
DataValueField="part_id" SelectedValue='<%# Bind("part_id") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Part") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="part_id" HeaderText="part_id" SortExpression="part_id"
Visible="False" />
<asp:BoundField DataField="quantity" HeaderText="Quantity" SortExpression="quantity" />
<asp:BoundField DataField="cost" DataFormatString="{0:C}" HeaderText="Price Per" SortExpression="cost" />
<asp:BoundField DataField="full_name" HeaderText="Entered By"
SortExpression="full_name" ReadOnly="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<EmptyDataTemplate>
No Parts Logged<br />
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:HiddenField ID="hfWOId" runat="server" Value='<%# Eval("wo_id") %>' />
<asp:HiddenField ID="hfDept" runat="server"
Value='<%# Eval("machine_type_id") %>' Visible = "false" />
<asp:HiddenField ID="hfMachine" runat="server"
Value='<%# Eval("machine_id") %>' />
<asp:HiddenField ID="hfReason" runat="server"
Value='<%# Eval("reason_id") %>' />
<asp:SqlDataSource ID="sqlDepartments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types] ORDER BY [type_description]">
</asp:SqlDataSource>
<asp:DropDownList ID="ddlDepartment" runat="server" DataSourceID="sqlDepartments" Visible = "false"
DataTextField="type_description" DataValueField="machine_type_id" SelectedValue='<%# Bind("machine_type_id") %>'
AutoPostBack="True"
onselectedindexchanged="ddlDepartment_SelectedIndexChanged">
</asp:DropDownList>
<br />
<asp:Label ID="Label30" runat="server" Font-Bold="true" Text="Machine Number:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachine" runat="server" Visible = "false">
</asp:DropDownList>
<br />
<asp:Label ID="Label10" runat="server" Font-Bold="true" Text="Serial Number:" Visible = "false"></asp:Label><asp:Label
ID="lblSerialNum" runat="server" Text='<% #Eval("serial_number") %>' Visible = "false"></asp:Label><asp:Label
ID="Label50" runat="server" Font-Bold="true" Text="Machine Status:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachineStatus" runat="server" DataSourceID="machineStatus" Visible = "false"
DataTextField="machine_status_desc" DataValueField="machine_status_id" SelectedValue='<%# Bind("machine_status_id") %>'>
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:Label ID="lblReason" runat="server" Text='<%# Eval("reason_desc") %>'></asp:Label> <br />
<asp:Label ID="Label29" runat="server" Text="Issued To:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblIssuedTo" runat="server" Text='<% #Eval("issue_to_desc") %>'></asp:Label><br />
<asp:Label ID="Label39" runat="server" Text="Description:" Font-Bold="true"></asp:Label><br />
<asp:Label ID="lblDescription" runat="server" Text='<% #Eval("work_order_desc") %>'></asp:Label><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label> 
<asp:Label ID="lblMaterial" runat="server" Text='<% #Eval("material_nbr_MATNR") %>' Visible="false"></asp:Label><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" Wrap="True" />
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:DropDownList
ID="ddlReason" runat="server">
</asp:DropDownList>
<asp:Label ID="Label29" runat="server" Font-Bold="true" Text="Issued To:"></asp:Label>
<asp:DropDownList ID="ddlIssuedTo" runat="server" DataSourceID="issuedTo" DataTextField="issue_to_desc"
DataValueField="issued_to" SelectedValue='<%# Bind("issued_to") %>'>
</asp:DropDownList>
<br />
<asp:Label ID="Label39" runat="server" Font-Bold="true" Text="Description:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="54px" Text='<%# Bind("work_order_desc") %>'
Width="273px" TextMode="MultiLine"></asp:TextBox><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label> 
<asp:DropDownList ID="ddlMaterial" runat="server" AppendDataBoundItems="True" Visible="false"
DataSourceID="sqlMaterials" DataTextField="material_nbr_MATNR"
DataValueField="material_nbr_MATNR"
SelectedValue='<%# Bind("material_nbr_MATNR") %>'>
<asp:ListItem Enabled="true" Text="None" Value="None" />
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label28" runat="server" Text="Requested By:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Text="Requested On:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Text="Required By:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequiredBy" runat="server" Text='<% #Eval("required_by", "{0:d}") %>'></asp:Label>
<br />
<asp:Label ID="Label77" runat="server" Text="WO Status:" Font-Bold="true"></asp:Label>
<asp:LinkButton ID="lbWOStatus" runat="server" Text='<% #Eval("status_description") %>'
CommandName="ChangeWOStatus"></asp:LinkButton>
<asp:DropDownList ID="ddlWOStatus" Visible="False" runat="server" AutoPostBack="True"
DataSourceID="woStatus" DataTextField="status_description" DataValueField="status_id"
OnSelectedIndexChanged="updateWOStatus" SelectedValue='<%# Bind("wo_status_id") %>'>
</asp:DropDownList>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="CancelStatusChange" Visible="False">Cancel</asp:LinkButton><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:Label ID="Label28" runat="server" Font-Bold="true" Text="Requested By:"></asp:Label>
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Font-Bold="true" Text="Requested On:"></asp:Label>
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Font-Bold="true" Text="Required By:"></asp:Label>
<asp:TextBox ID="txtRequiredBy" runat="server" Text='<%# Bind("required_by") %>'
Width="100px"></asp:TextBox><br />
<asp:Label ID="Label77" runat="server" Font-Bold="true" Text="WO Status:"></asp:Label>
<asp:Label ID="lblWOStatus" runat="server" Text='<%# Eval("status_description") %>'></asp:Label>
<br />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" Enabled="True" SelectedDate='<%# Eval("required_by") %>'
TargetControlID="txtRequiredBy">
</asp:CalendarExtender>
<asp:LinkButton ID="lbWOStatus" runat="server" CommandName="ChangeWOStatus" Text='<% #Eval("status_description") %>'
Visible="False"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnApprove" runat="server" Text="Approve" BackColor="#00C000" Font-Size="Medium"
Height="40px" Width="70px" CommandName="Approve" />
<br />
<asp:Button ID="btnDeny" runat="server" Text="Deny" BackColor="#C00000" Font-Size="Medium"
ForeColor="Black" Height="40px" Width="70px" CommandName="Deny" />
<br />
<asp:Label ID="lblPending" runat="server" Text="Pending Approval" Visible="False"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hfPriority" runat="server" Value='<%# Eval("priority", "{0:N}") %>' />
<asp:HiddenField ID="hfApprovalStatus" runat="server" Value='<% #Eval("approval_status_id") %>' />
<asp:ImageButton ID="btnTopPriority" runat="server" CommandName="MakeTopPriority"
ImageUrl="~/App_Themes/Images/priority.png" /><br />
<asp:ImageButton ID="btnUp" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/upArrow.png"
Width="40px" CommandName="Up" /><br />
<asp:ImageButton ID="btnDown" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/downArrow.png"
Width="40px" CommandName="Down" /><br />
<asp:LinkButton ID="lbChangePriority" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="ChangePriority">Notify New Priority</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="DeleteWO">Delete</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbMoveToProjects" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="MoveToProjects" OnClientClick="javascript:return confirm('Are you sure you want to move this to projects?')" Visible="false">Move To Projects</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbEngineeringChange" runat="server" CommandArgument='<%# Eval("wo_id") %>' CommandName="EngineeringChange" Visible="false">Push For Engineering Change</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbPrintISO" runat="server" CommandName="PrintISO">Print ISO</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No work orders.<br />
</EmptyDataTemplate>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</center>
<br />'
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<center>
<asp:SqlDataSource ID="workOrders" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="sp_WorkOrders"
UpdateCommand="UPDATE fact_work_orders SET machine_id = #machine_id, reason_id = #reason_id, machine_status_id = #machine_status_id, issued_to = #issued_to, work_order_desc = #work_order_desc, material_nbr_MATNR = #material_nbr_MATNR, required_by = #required_by WHERE wo_id = #wo_id"
SelectCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="machine_id" />
<asp:Parameter Name="reason_id" />
<asp:Parameter Name="machine_status_id" />
<asp:Parameter Name="issued_to" />
<asp:Parameter Name="work_order_desc" />
<asp:Parameter Name="material_nbr_MATNR" />
<asp:Parameter Name="required_by" />
<asp:Parameter Name="wo_id" Type="Int16" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="issuedTo" QueryStringField="issuedTo" DefaultValue="0" />
<asp:QueryStringParameter Name="woStatus" QueryStringField="woStatus" Type="String"
DefaultValue="%" />
<asp:SessionParameter DefaultValue="0" Name="level" SessionField="level" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="woStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [status_description], [status_id] FROM [list_wo_status] WHERE ([status_id] <> #status_id)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="status_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="machineStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [machine_status_desc], [machine_status_id] FROM [list_machine_status]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="departments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="issuedTo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [issued_to], [issue_to_desc] FROM [list_issued_to]"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqlMaterials" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [material_nbr_MATNR] FROM [vdim_materials] ORDER BY [material_nbr_MATNR]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="partsUsed" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [fact_parts_used] WHERE [parts_used_id] = #parts_used_id"
InsertCommand="INSERT INTO [fact_parts_used] ([wo_id], [part_id], [quantity]) VALUES (#wo_id, #part_id, #quantity)"
SelectCommand="SELECT * FROM
(SELECT parts_used_id, dim_users.[user_name], full_name,
wo_id as tasks,
fact_parts_used.part_id, dim_parts.part_number+' '+dim_parts.part_desc as Part, quantity, cost
FROM fact_parts_used
INNER JOIN dim_users ON dim_users.[user_id] = fact_parts_used.[user_id]
INNER JOIN dim_parts ON dim_parts.part_id = fact_parts_used.part_id
) a
WHERE tasks is not null AND tasks = tasks "
UpdateCommand="UPDATE [fact_parts_used] SET [part_id] = #part_id, [quantity] = #quantity, cost = #cost WHERE [parts_used_id] = #parts_used_id"
>
<SelectParameters>
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="parts_used_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
<asp:Parameter Name="parts_used_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="wo_id" Type="Int32" />
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</center>
</asp:Content>
Related
I am using a GridView bound to a list of objects rather than a direct SQL query. The population of this if working and so are the updates. I have manually generated the insert for this gridview and this is working as well.
When trying to run the delete command from the gridview, the correct method is being called however none of the parameters are being populated. The only required parameter for this is #ID however, reading other posts, the general fix has been to add all parameters, but still to no avail.
<asp:GridView ID="GridViewBands" runat="server" AutoGenerateColumns="False" DataSourceID="BandsDataSource" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Width="1375px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField HeaderText="AgencyID" SortExpression="AgencyID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Width="80px" Text='<%# Bind("AgencyID") %>' ReadOnly ="true"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" runat="server" ErrorMessage="there is an error?" Text="*`"></asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add New Line" />
<asp:TextBox ID="newAgencyID" runat="server" Width="80px"></asp:TextBox>
<br />
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("AgencyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TypeID" SortExpression="TypeID">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Width="80px" Text='<%# Bind("TypeID") %>' ReadOnly ="true"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newTypeID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Width="80px" Text='<%# Bind("TypeID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CompanyID" SortExpression="CompanyID">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Width="80px" Text='<%# Bind("CompanyID") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newCompanyID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("CompanyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Office" SortExpression="Office">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Width="80px" Text='<%# Bind("Office") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newOffice" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Office") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SequenceID" SortExpression="SequenceID" >
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Width="80px" Text='<%# Bind("SequenceID") %>' ReadOnly ="true"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newSequenceID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("SequenceID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Minimmum" SortExpression="Minimmum">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Width="80px" Text='<%# Bind("Minimmum") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newMinimum" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Minimmum") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Capped" SortExpression="Capped">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Width="80px" Text='<%# Bind("Capped") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newCapped" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Capped") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="fixed" SortExpression="fixed">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Width="80px" Text='<%# Bind("fixed") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newFixed" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("fixed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Flat" SortExpression="Flat">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Width="80px" Text='<%# Bind("Flat") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newFlat" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Flat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SequenceLimit" SortExpression="SequenceLimit">
<EditItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Width="80px" Text='<%# Bind("SequenceLimit") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newSequenceLimit" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("SequenceLimit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate" SortExpression="Rate">
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server" Width="80px" Text='<%# Bind("Rate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newRate" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("Rate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActiveFrom" SortExpression="ActiveFrom">
<EditItemTemplate>
<asp:TextBox ID="txtActiveFrom" runat="server" Width="200px" Text='<%# Bind("ActiveFrom") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newActiveFrom" runat="server" Width="200px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblActiveFrom" runat="server" Text='<%# Bind("ActiveFrom") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActiveTo" SortExpression="ActiveTo">
<EditItemTemplate>
<asp:TextBox ID="txtActiveTo" runat="server" Width="200px" Text='<%# Bind("ActiveTo") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newActiveTo" runat="server" Width="200px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblActiveTo" runat="server" Text='<%# Bind("ActiveTo") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" SortExpression="ID">
<EditItemTemplate>
<asp:TextBox ID="txtID" runat="server" Width="80px" Text='<%# Bind("ID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
The data source is as below, with the other working methods. It is just the delete method that isn't populating any of the parameters.
<asp:ObjectDataSource ID="BandsDataSource" runat="server" SelectMethod="SelectBands" TypeName="App_Code.Billing+BillingBand" UpdateMethod="UpdateBands" DeleteMethod="RemoveBand" InsertMethod="AddNewBand">
<SelectParameters>
<asp:Parameter Name ="AgencyID" Type ="Int64" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="AgencyID" Type="Object" />
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="AgencyID" Type="Object" />
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="AgencyID" Type="Object"/>
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</UpdateParameters>
</asp:ObjectDataSource>
I have tried to manually populate the parameters being using similar to the below, however I have not been able to find a way to populate the parameter based on the 'selected' line for deletion.
Protected Sub BandsDataSource_Deleting(sender As Object, e As ObjectDataSourceMethodEventArgs) Handles BandsDataSource.Deleting
e.InputParameters("ID") = GridViewBands.SelectedRow.ID.ToString()
End Sub
But this is returning a NULL reference exception.
This is the delete method for example, the update and add methods are in the same format and are working correctly.
Public Sub RemoveBand(AgencyID, TypeID, CompanyID, Office, SequenceID, Minimmum, Capped, fixed, Flat, SequenceLimit, Rate, ActiveFrom, ActiveTo, ID)
Using lCon As SqlConnection = Database.DBConnection
Dim lSqlText As String = "update billing_bands set active_to = getdate() where id = #id"
Dim lSqlCmd As New SqlCommand(lSqlText, lCon)
With lSqlCmd.Parameters
.AddWithValue("#id", ID)
End With
lSqlCmd.ExecuteNonQuery()
End Using
End Sub
Had to add into the GridView the onRowDeleting param which has to set the default values for the variables used for the delete.
<asp:GridView ID="GridViewBands" runat="server" AutoGenerateColumns="False" DataSourceID="BandsDataSource" OnRowDeleting="test" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Width="1375px">
<AlternatingRowStyle BackColor="White" />
<Columns>
Protected Sub test(sender As Object, e As GridViewDeleteEventArgs)
Dim thisID As Integer = e.Values(13)
BandsDataSource.DeleteParameters("ID").DefaultValue = thisID
BandsDataSource.Delete()
BandsDataSource.DataBind()
BandsDataSource.Dispose()
End Sub
this is my code when i click on checkbox chkall , all checkboxes should be activated.
so can please anyone help me
<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand" CellPadding="4" ForeColor="#333333">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
<asp:CheckBox ID="chkall" runat="server" onclick="checktrue()" />
EMPID ENAME DESIGNATION DOJ SALARY DEPTNO Edit/Update
</HeaderTemplate>
<ItemStyle BackColor="#EFF3FB" />
<ItemTemplate>
<asp:CheckBox ID="chkone" runat="server" />
<asp:Label ID="lblempid" runat="server" Text='<%#Eval("empid") %>' />
<%#Eval("ename") %>
<%#Eval("desg") %>
<%#Eval("doj") %>
<%#Eval("salary") %>
<%#Eval("deptno") %>
<asp:Button ID="btnedit" runat="server" Text="EDIT" CommandName="Edit" />
</ItemTemplate>
<AlternatingItemStyle BackColor="White" />
<EditItemTemplate>
<asp:Label ID="lblempid" runat="server" Text='<%#Eval("empid") %>' />
<asp:TextBox ID="txtename" runat="server" Text='<%#Eval("ename") %>' />
<asp:TextBox ID="txtdesg" runat="server" Text='<%#Eval("desg") %>' />
<asp:TextBox ID="txtdoj" runat="server" Text='<%#Eval("doj") %>' />
<asp:TextBox ID="txtsalary" runat="server" Text='<%#Eval("salary") %>' />
<asp:TextBox ID="txtdeptno" runat="server" Text='<%#Eval("deptno") %>' />
<asp:Button ID="btnupdate" runat="server" Text="Update" CommandName="Update" />
<asp:Button ID="btncancel" runat="server" Text="Cancel" CommandName="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btmdelete" runat="server" OnClick="btndelete_Click" Text="Delete" />
<asp:TextBox ID="txtempid" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtename" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdesg" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdoj" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtsalary" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdeptno" runat="server" Width="60"></asp:TextBox>
<asp:Button ID="btnadd" runat="server" Text="add" CommandArgument="add" />
</FooterTemplate>
<SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:DataList>
I recommend doing it on the client side. Here is an example with jquery
function checkAll(){
$("#DataList1 :checkbox").prop("checked", $("#chkall").prop("checked"));
}
I am trying to work on Chapter 15 exercise from Murach’s ASP.NET 4.5 web programming with C# 2012.
Here is my question.
The webpage has Grid View on the left and Details View on the right.
When I update Ahmed to Ahmad from DetailViews,
the update is not reflected in GridView.
I have to go to the next page and then come back to previous page
in order for the update to display.
I am wondering if there is any solution.
Thank you for your help!
By the way, the code is copied from the book.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Chapter 15: Customer Maintenance</title>
<link href="Main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<img src="Images/banner.jpg" "Halloween Store" />
</header>
<section>
<form id="form1" runat="server">
<div id="gridview">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
DataKeyNames="Email" DataSourceID="SqlDataSource1"
SelectedIndex="0"
AutoGenerateColumns="False" CellPadding="4" GridLines="None"
ForeColor="Black" Width="320px" >
<Columns>
<asp:BoundField DataField="Email" HeaderText="Email"
ReadOnly="True" Visible="False">
</asp:BoundField>
<asp:BoundField DataField="LastName" HeaderText="LastName">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="FirstName" HeaderText="FirstName">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="120px" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
</Columns>
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="Black" />
<AlternatingRowStyle BackColor="#E3EAEB" ForeColor="Black" />
<SelectedRowStyle BackColor="#F46D11" ForeColor="White" />
<PagerSettings Mode="NextPreviousFirstLast" />
<PagerStyle BackColor="#1C5E55" ForeColor="White"
HorizontalAlign="Center" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:HalloweenConnectionString %>"
OldValuesParameterFormatString ="original_{0}"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [Customers]
WHERE [Email] = #original_Email
AND [LastName] = #original_LastName
AND [FirstName] = #original_FirstName
AND [Address] = #original_Address
AND [City] = #original_City
AND [State] = #original_State
AND [ZipCode] = #original_ZipCode
AND [PhoneNumber] = #original_PhoneNumber"
InsertCommand="INSERT INTO [Customers] ([Email], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber])
VALUES (#Email, #LastName, #FirstName, #Address, #City, #State, #ZipCode, #PhoneNumber)"
SelectCommand="SELECT [Email], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber]
FROM [Customers] WHERE ([Email] = #Email)"
UpdateCommand="UPDATE [Customers] SET [Email] = #Email,
[LastName] = #LastName,
[FirstName]= #FirstName,
[Address] = #Address, [City] = #City, [State] = #State, [ZipCode] = #ZipCode,
[PhoneNumber] = #PhoneNumber
WHERE [Email] = #original_Email
AND [LastName] = #original_LastName
AND [FirstName] = #original_FirstName
AND [Address] = #original_Address AND [City] = #original_City AND [State] = #original_State AND [ZipCode] = #original_ZipCode
AND [PhoneNumber] = #original_PhoneNumber">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="Email" PropertyName="SelectedValue" Type="String"/>
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_PhoneNumber" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="PhoneNumber" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_PhoneNumber" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="PhoneNumber" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HalloweenConnectionString %>"
SelectCommand="SELECT [Email], [LastName], [FirstName]
FROM [Customers] ORDER BY [LastName]">
</asp:SqlDataSource>
</div>
<div id="detailsview">
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="363px" AutoGenerateRows="False" DataKeyNames="Email" DataSourceID="SqlDataSource2" style="margin-left: 0px">
<Fields>
<asp:TemplateField HeaderText="Email">
<ItemTemplate>
<asp:Label ID="lblEmailIT" runat="server" Text='<%# Bind("Email") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblEmailET" runat="server" Text='<%# Bind("Email") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="txtEmailInT" runat="server" Text='<%# Bind("Email") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmailInT" ErrorMessage="Email is a required field.">
</asp:RequiredFieldValidator>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName">
<ItemTemplate>
<asp:Label ID="lblLastNameIT" runat="server" Text='<%# Bind("LastName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblLastNameET" runat="server" Text='<%# Bind("LastName") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblLastNameInT" runat="server" Text='<%# Bind("LastName") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="FirstName">
<ItemTemplate>
<asp:Label ID="lblFirstNameIT" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblFirstNameET" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblFirstNameInT" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="lblAddressIT" runat="server" Text='<%# Bind("Address") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblAddressET" runat="server" Text='<%# Bind("Address") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblAddressInT" runat="server" Text='<%# Bind("Address") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="lblCityIT" runat="server" Text='<%# Bind("City") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblCityET" runat="server" Text='<%# Bind("City") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblCityInT" runat="server" Text='<%# Bind("City") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="lblStateIT" runat="server" Text='<%# Bind("State") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblStateET" runat="server" Text='<%# Bind("State") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblStateInT" runat="server" Text='<%# Bind("State") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ZipCode">
<ItemTemplate>
<asp:Label ID="lblZipCodeIT" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblZipCodeET" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblZipCodeInT" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="PhoneNumber">
<ItemTemplate>
<asp:Label ID="lblPhoneNumberIT" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblPhoneNumberET" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblPhoneNumberInT" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" ShowEditButton="true" ShowInsertButton="true" />
</Fields>
</asp:DetailsView>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="Please correct the following errors:" CssClass="error" />
<p>
<asp:Label ID = "lblError" runat="server" EnableViewState="False" CssClass="error">
</asp:Label>
</p>
</div>
</form>
</section>
</body>
</html>
Yes, in your behind code under the Page_Load method insert
if(!Page.IsPostBack)
{
GridView1.DataBind();
}
You have to use this event into this event you can bind the Gridview and to redirect the the same page your data will be reflected on your Gridview
Hope this will help try this....
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
if (e.AffectedRows == 1)
{
GridView1.DataBind();
Response.Redirect("Yourpage.aspx");
}
}
What is happening: I'm trying to update a patient table in a gridview table using a stored procedure.
Error:
'DropDownList2' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
Here is my procedure:
ALTER PROCEDURE dbo.uspPatientUpdate
#ID int,
#OHIP char(10),
#FirstName nvarchar(20),
#LastName nvarchar(40),
#DOB date,
#VisitsPerYear int,
#DoctorID int
AS
BEGIN
SET NOCOUNT OFF
UPDATE Patient
SET OHIP = #OHIP,
FirstName = #FirstName,
LastName = #LastName,
DOB = #DOB,
VisitsPerYear = #VisitsPerYear,
DoctorID = #DoctorID
WHERE ID = #ID
END
Here is my asp:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="MedicalOffice.aspx.cs" Inherits="MedicalOffice" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Maintain Patients</h1>
<p>Select Patient By Doctor:<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="sdDoctorList" DataTextField="Doctor" DataValueField="ID">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" DataSourceID="sdPatient" GridLines="Horizontal">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField HeaderText="OHIP" SortExpression="OHIP">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("OHIP") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("OHIP") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" SortExpression="LastName">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DOB" SortExpression="DOB">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("DOB") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Visits Per Year" SortExpression="VisitsPerYear">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("VisitsPerYear") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("VisitsPerYear") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Doctor" SortExpression="Doctor">
<EditItemTemplate>
#<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="sdDoctorList" DataTextField="Doctor" DataValueField="ID">#
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Doctor") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#487575" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#275353" />
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal" HeaderText="Insert Patient" Height="50px" Width="125px">
<EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:TemplateField HeaderText="OHIP" SortExpression="OHIP">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("OHIP") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("OHIP") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("OHIP") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName" SortExpression="LastName">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DOB" SortExpression="DOB">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("DOB") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("DOB") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VisitsPerYear" SortExpression="VisitsPerYear">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("VisitsPerYear") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("VisitsPerYear") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("VisitsPerYear") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Doctor" SortExpression="Doctor">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Doctor") %>'></asp:Label>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="sdDoctorList" DataTextField="Doctor" DataValueField="ID" SelectedValue='<%# Bind("Doctor") %>'>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Doctor") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#333333" />
</asp:DetailsView>
<asp:SqlDataSource ID="sdDoctorList" runat="server" ConnectionString="<%$ ConnectionStrings:MedicalOfficeConnectionString %>" SelectCommand="uspDoctorList" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</p>
</div>
<asp:SqlDataSource ID="sdPatient" runat="server" ConnectionString="<%$ ConnectionStrings:MedicalOfficeConnectionString %>" DeleteCommand="usp_PatientDelete" InsertCommand="uspPatientInsert" SelectCommand="uspPatientSelectByIDOrSelectAll" UpdateCommand="uspPatientUpdate" SelectCommandType="StoredProcedure" DeleteCommandType="StoredProcedure" InsertCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="OHIP" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter DbType="Date" Name="DOB" />
<asp:Parameter Name="VisitsPerYear" Type="Int32" />
<asp:Parameter Name="DoctorID" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="doctorID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="OHIP" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter DbType="Date" Name="DOB" />
<asp:Parameter Name="VisitsPerYear" Type="Int32" />
<asp:Parameter Name="DoctorID" Type="Int32" />
<asp:Parameter Name="Timestamp" Type="Object"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Please fix the following:" />
</form>
</body>
</html>
uspPatientUpdate is missing the TimeStamp parameter:
<UpdateParameters>
...
<asp:Parameter Name="Timestamp" Type="Object"></asp:Parameter>
</UpdateParameters>
Or, perhaps it isn't missing it and you simply shouldn't specify it in the markup.
I have a gridview that uses accessdatasource which has select, insert, delete and update. It used to work before perfectly but all of a sudden the update stopped working while the rest are still working as they supposed to be. I haven't changed anything in the gridview or datasource, but I added new fields to the table but are not displayed in gridview. I tested by deleting the new fields from the table which did not work either. Refreshed the datasoure and gridview as well. Here is the code
asp:GridView ID="GridView1" runat="server" AllowSorting="True"
ShowFooter="True" EmptyDataText="There are no records for the selection"
AutoGenerateColumns="False" CellPadding="4" OnRowCommand="Insert_Click"
OnRowUpdating="beforeUpdate"
DataKeyNames="Lab Name,Target,Device Name"
ForeColor="#333333" HorizontalAlign="Center"
EmptyDataRowStyle-HorizontalAlign="Center"
EmptyDataRowStyle-VerticalAlign="Middle" Width="1333px"
DataSourceID="AccessDataSource8">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EmptyDataRowStyle Wrap="False" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure?');" ></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="LinkButton" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="validate" ></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lab Name" SortExpression="Lab Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("[Lab Name]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("[Lab Name]") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLabname" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="LabName" runat="server" ControlToValidate="txtLabname" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Target" SortExpression="Target">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Target") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Target") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTarget" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Target" runat="server" ControlToValidate="txtTarget" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Device Name" SortExpression="Device Name">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("[Device Name]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("[Device Name]") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtDevicename" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Devicename" runat="server" ControlToValidate="txtDevicename" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IO Type Requirement"
SortExpression="IO Type Requirement">
<ItemTemplate>
<asp:Label ID="Label4" runat="server"
Text='<%# Bind("[IO Type Requirement]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("[IO Type Requirement]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtIotyperequirement" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Iotyperequirement" runat="server" ControlToValidate="txtIotyperequirement" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Number" SortExpression="Part Number">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("[Part Number]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("[Part Number]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPartnumber" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Partnumber" runat="server" ControlToValidate="txtPartnumber" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub Part" SortExpression="Sub Part">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("[Sub Part]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("[Sub Part]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSubpart" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Subpart" runat="server" ControlToValidate="txtSubpart" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subpart Description"
SortExpression="Subpart Description">
<ItemTemplate>
<asp:Label ID="Label7" runat="server"
Text='<%# Bind("[Subpart Description]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("[Subpart Description]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSubpartdesc" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Subpartdesc" runat="server" ControlToValidate="txtSubpartdesc" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" VerticalAlign="Middle" Wrap="False" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
VerticalAlign="Middle" Wrap="False" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource8" runat="server" CancelSelectOnNullParameter="False"
DataFile="~/App_Data/Test.mdb"
SelectCommand="SELECT Lab1.[Lab Name], Lab1.[Target], Lab1.[Device Name], Lab1.[IO Type Requirement], Lab1.[Part Number], Lab1.[Sub Part], Lab1.[Subpart Description]
FROM Lab1
WHERE
(((Lab1.[Lab Name])= [WhichLab] OR [WhichLab] = '0') AND
((Lab1.[Target])= [WhichTarget] OR [WhichTarget] = '0') AND
((Lab1.[Device Name])= [WhichDevice] OR [WhichDevice] = '0') AND
((Lab1.[IO Type Requirement])= [Whichiotyperequirement] OR [Whichiotyperequirement] = '0') AND
((Lab1.[Part Number])= [WhichPartNumber] OR [WhichPartNumber] = '0') AND
((Lab1.[Sub Part])= [WhichSubPart] OR [WhichSubPart] = '0') AND
((Lab1.[Subpart Description])= [WhichSubPartDesc] OR [WhichSubPartDesc] = '0')
)" UpdateCommand= " UPDATE [Lab1] SET [IO Type Requirement]= ?, [Part Number]= ?, [Sub Part]= ?, [Subpart Description]= ?
WHERE ([Lab Name]= ?) AND ([Target]= ?) AND ([Device Name] = ?)"
InsertCommand= "INSERT INTO LAB1 ([Lab Name],[Target],[Device Name],[IO Type Requirement],[Part Number],[Sub Part],[Subpart Description]) VALUES
([WhichLab],[WhichTarget],[WhichDevice],[Whichiotyperequirement],[WhichPartNumber],[WhichSubPart],[WhichSubPartDesc]) "
DeleteCommand= " Delete from LAB1 WHERE LAB1.[Lab Name]= [WhichLab] AND Lab1.[Target]=[WhichTarget] AND Lab1.[Device Name]=[WhichDevice]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Lab Name" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList2" Name="Target" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList3" Name="Device Name" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList4" Name="IO Type Requirement" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList5" Name="Part Number" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList6" Name="Sub Part" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList7" Name="Subpart Description" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="IO Type Requirement" Type="String"/>
<asp:Parameter Name="Part Number" Type="String"/>
<asp:Parameter Name="Sub Part" Type="String" />
<asp:Parameter Name="Subpart Description" Type="String"/>
<asp:Parameter Name="Lab Name" Type="String"/>
<asp:Parameter Name="Target" Type="String"/>
<asp:Parameter Name="Device Name" Type="String"/>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Lab Name" Type="String" />
<asp:Parameter Name="Target" Type="String" />
<asp:Parameter Name="Device Name" Type="String" />
<asp:Parameter Name="IO Type Requirement" Type="String" />
<asp:Parameter Name="Part Number" Type="String" />
<asp:Parameter Name="Sub Part" Type="String" />
<asp:Parameter Name="Subpart Description" Type="String" />
</InsertParameters>
<DeleteParameters>
<asp:Parameter Name="Lab Name" Type="String" />
<asp:Parameter Name="Target" Type="String" />
<asp:Parameter Name="Device Name" Type="String" />
</DeleteParameters>
</asp:AccessDataSource>
One of the fields in your WHERE clause:
WHERE ([Lab Name]= ?) AND ([Target]= ?) AND ([Device Name] = ?)"
...is not matching records. Maybe there are trailing spaces in one or more of the fields.
"ABC" will not match "ABC "