my question is about how to go about updating data in a ASP.NET listview using a stored procedure.
I'm getting an error message whenever I try to update any data in my listview stating that my stored procedure has too many arguments specified.
I've looked through all of my code and all of my arguments seem to match up with my stored procedure so I think it might have to do with how I created the listview (just dragging and dropping it in design view using visual studio 2015) or it's something wrong with my stored procedure.
I've been stuck on this issue for about a day now and I feel like I'm missing something real simple here but can't quite put my finger on it.
If anyone could help my out I would greatly appreciate it. This app I'm working on uses vb.net as it's back-end and used ASP.NET web forms. Below is the code for the page I'm working on.
ASP.NET Page (Might not work properly since it uses a master page and some other external resources)
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPages/MasterPage.Master" CodeBehind="CodeManagement.aspx.vb" Inherits="OcasNS.CodeManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderInHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH1_DontUseInAContentPageItsJustForTheseJavaScriptFiles" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<p>Course Code:<asp:TextBox ID="TextBox1" runat="server" Height="18px"></asp:TextBox>
</p>
<br />
<p>Course Title:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<br />
<p>Class/Group:<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</p>
<p>Career Tech Course Type:
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OKECSTestConnectionString %>" SelectCommand="spCodeManagementLookup" SelectCommandType="StoredProcedure" UpdateCommand="spCodeManagementUpdate" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="ClassGroupID" Type="Int32" />
<asp:Parameter Name="CourseDescription" Type="String" />
<asp:Parameter Name="ClassSubjectCode" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ClassGroupID" DataSourceID="SqlDataSource1">
<AlternatingItemTemplate>
<tr style="background-color:#FFF8DC;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<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="ClassGroupIDLabel1" runat="server" Text='<%# Eval("ClassGroupID") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:TextBox ID="ClassSubjectCodeTextBox" runat="server" Text='<%# Bind("ClassSubjectCode") %>' />
</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>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td> </td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:TextBox ID="ClassSubjectCodeTextBox" runat="server" Text='<%# Bind("ClassSubjectCode") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server"></th>
<th runat="server">ClassGroupID</th>
<th runat="server">Description</th>
<th runat="server">ClassSubjectCode</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<br />
<br />
<button type="button">Save</button>
<button type="button">Cancel</button>
<button type="button">Export To Excel</button>
</asp:Content>
Update Stored Procedure (The one causing the error)
#ClassGroupID INT,
#CourseDescription VARCHAR(100),
#ClassSubjectCode VARCHAR(20)
UPDATE [dbo].[tb_oecs_CodeClassGroup]
SET [Description] = #CourseDescription
, [ClassSubjectCode] = #ClassSubjectCode
WHERE ClassGroupID = #ClassGroupID
Lookup Stored Procedure (This loads the data into the Listview)
SELECT DISTINCT
g.ClassGroupID
,g.Description
,g.ClassSubjectCode
FROM tb_oecs_CodeClassGroup g
JOIN tb_oecs_CodeClass c
ON g.ClassGroupID = c.ClassGroupID
ORDER BY g.ClassGroupID
Related
I have a ListView which has many templates (InsertItemTemplate, AlternatingItemTemplate, EditItemTemplate, EmptyDataTemplate, ItemTemplate, LayoutTemplate, SelectedItemTemplate)
I have this datasource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CouncilsConnectionString %>"
SelectCommand="SELECT [EmpID], [EmpName], [UserName], [password], [Email], [Mobile] FROM [Emp] WHERE ([FlageDel] = #FlageDel)"
DeleteCommand="DELETE FROM Emp WHERE (EmpId = #did)"
InsertCommand="INSERT INTO Emp(EmpName, UserName, password, Email, Mobile) VALUES (#inm, #ius, #ips, #iem, #imob)"
UpdateCommand="UPDATE Emp SET EmpName = #ename, UserName = #nm, password = #ps, Email = #em, Mobile = #mob WHERE (EmpId = #eid)">
<DeleteParameters>
<asp:Parameter Name="did" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="inm" />
<asp:Parameter Name="ius" />
<asp:Parameter Name="ips" />
<asp:Parameter Name="iem" />
<asp:Parameter Name="imob" />
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="FlageDel" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ename" />
<asp:Parameter Name="nm" />
<asp:Parameter Name="ps" />
<asp:Parameter Name="em" />
<asp:Parameter Name="mob" />
<asp:Parameter Name="eid" />
</UpdateParameters>
</asp:SqlDataSource>
And in the ItemTemplate I have
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Update" />
</td>
I want to know how can I associate the delete button with the data source command so that it deletes the item when the button is clicked. The same thing for update\insert operations.
Here is the entire ListView Code
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" InsertItemPosition="LastItem">
<AlternatingItemTemplate>
<tr style="background-color: #FFFFFF;color: #000000;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument="#did" Text="حذف" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="تعديل" />
</td>
<td>
<asp:Label ID="EmpNameLabel" runat="server" Text='<%# Eval("EmpName") %>' />
</td>
<td>
<asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
</td>
<td>
<asp:Label ID="passwordLabel" runat="server" Text='<%# Eval("password") %>' />
</td>
<td>
<asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
</td>
<td>
<asp:Label ID="MobileLabel" runat="server" Text='<%# Eval("Mobile") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color: #999999;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" CommandArgument="#eid" Text="حفظ" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="إلغاء" />
</td>
<td>
<asp:TextBox ID="EmpNameTextBox" runat="server" Text='<%# Bind("EmpName") %>' />
</td>
<td>
<asp:TextBox ID="UserNameTextBox" runat="server" Text='<%# Bind("UserName") %>' />
</td>
<td>
<asp:TextBox ID="passwordTextBox" runat="server" Text='<%# Bind("password") %>' />
</td>
<td>
<asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
</td>
<td>
<asp:TextBox ID="MobileTextBox" runat="server" Text='<%# Bind("Mobile") %>' />
</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>ليس هناك أي بيانات حاليا.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="إضافة" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="مسح" />
</td>
<td>
<asp:TextBox ID="EmpNameTextBox" runat="server" Text='<%# Bind("EmpName") %>' />
</td>
<td>
<asp:TextBox ID="UserNameTextBox" runat="server" Text='<%# Bind("UserName") %>' />
</td>
<td>
<asp:TextBox ID="passwordTextBox" runat="server" Text='<%# Bind("password") %>' />
</td>
<td>
<asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
</td>
<td>
<asp:TextBox ID="MobileTextBox" runat="server" Text='<%# Bind("Mobile") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color: #EEE;color: black;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="حذف" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="تعديل" />
</td>
<td>
<asp:Label ID="EmpNameLabel" runat="server" Text='<%# Eval("EmpName") %>' />
</td>
<td>
<asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
</td>
<td>
<asp:Label ID="passwordLabel" runat="server" Text='<%# Eval("password") %>' />
</td>
<td>
<asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
</td>
<td>
<asp:Label ID="MobileLabel" runat="server" Text='<%# Eval("Mobile") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server" style="direction: rtl; width: 100%">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; vertical-align: middle">
<tr runat="server" style="background-color: #5D7B9D;color: #FFF;">
<th runat="server" style="text-align: center"></th>
<th runat="server" style="text-align: center">الاسم</th>
<th runat="server" style="text-align: center">اسم المستخدم</th>
<th runat="server" style="text-align: center">كلمة المرور</th>
<th runat="server" style="text-align: center">الايميل</th>
<th runat="server" style="text-align: center">الجوال</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">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color: #E2DED6;font-weight: bold;color: #333333;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="حذف" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="تعديل" />
</td>
<td>
<asp:Label ID="EmpNameLabel" runat="server" Text='<%# Eval("EmpName") %>' />
</td>
<td>
<asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
</td>
<td>
<asp:Label ID="passwordLabel" runat="server" Text='<%# Eval("password") %>' />
</td>
<td>
<asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
</td>
<td>
<asp:Label ID="MobileLabel" runat="server" Text='<%# Eval("Mobile") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
Sorry for the delay, but is the delete button not working? generally when you use the templates, it automatically sets it all up so when you click the delete button it runs the deletecommand. However, the Parameters you currently have
<InsertParameters>
<asp:Parameter Name="inm" />
<asp:Parameter Name="ius" />
<asp:Parameter Name="ips" />
<asp:Parameter Name="iem" />
<asp:Parameter Name="imob" />
</InsertParameters>
Don't seem to be really doing any thing, you need to add what they should be expecting. IE string, char, int... something along those lines.
The other part, is the command argument that you have added to your buttons. I don't think you need that.
Sorry if this is super late and you already figured it out.
I am getting an error DataBinding: "'System.Data.DataRowView' does not contain a property with the name 'p'" in one query within the following code.
It shows error in this line:
<asp:Label ID="lblPharmName" runat="server" Text='<%# String.Format("{0} {1}", Eval("p.Pharm_fname"), Eval("p.Pharm_lname")) %>'>
</asp:Label>
Below is the code. But I am suspecting the query used. Any suggestion will be appreciated in finding what is causing the error to be returned.
Thank you
<%# Page Language="VB" MasterPageFile="~/CIOSMasterNonAuth.master" AutoEventWireup="false" CodeFile="ViewOrders.aspx.vb" Inherits="ViewOrders" title="Untitled Page" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<%--<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>--%>
<asp:Table runat="server" Font-Size="Small" HorizontalAlign="Center">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">
<asp:Label runat="server">Order Status: </asp:Label>
</asp:TableCell>
<asp:TableCell HorizontalAlign="Left">
<asp:DropDownList ID="OrderStatusDropDownList" runat="server" AutoPostBack="True">
<asp:ListItem Text="Verified" Value="V" />
<asp:ListItem Text="New" Value="N" />
<asp:ListItem Text="Cancelled" Value="C" />
</asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table border="1" visible="false">
<tr>
<th>
Web Order ID
</th>
<th>
Web Entry Date
</th>
<th>
Protocol Number
</th>
<th>
Site Number
</th>
<th>
Pharmacist of Record
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:LinkButton runat="server" ID="lnkOrderDetails" Text='<%# Eval("web_order_id") %>' OnClick="lnkOrderDetails_Click" />
</td>
<td>
<asp:Label ID="lblWebEntryDate" runat="server" Text='<%# Eval("web_entry_date") %>'>
</asp:Label>
</td>
<td>
<asp:Label ID="lblProtocolNum" runat="server" Text='<%# Eval("protocol_num") %>'>
</asp:Label>
</td>
<td>
<asp:Label ID="lblSiteNum" runat="server" Text='<%# Eval("site_num") %>'>
</asp:Label>
</td>
<td>
<asp:Label ID="lblPharmName" runat="server" Text='<%# String.Format("{0} {1}", Eval("p.Pharm_fname"), Eval("p.Pharm_lname")) %>'>
</asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnShowModalPopup"
PopupControlID="divPopUp"
PopupDragHandleControlID="panelDragHandle">
</cc1:ModalPopupExtender>
<div id="divPopUp" style="display:none; font-family:Georgia; font-size:small;">
<asp:Panel runat="Server" ID="panelDragHandle" BackColor="#009999" BorderColor="ActiveBorder" BorderStyle="Ridge" ForeColor="White" Width="800px">
<table width="100%">
<tr>
<td>
Hold here to Drag this Box
</td>
<td align="right">
<asp:Label runat="server" ID="lblText" Text="Web OrderID: " ForeColor="White"></asp:Label>
<asp:Label ID="lblWebOrderID" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="GridView2" runat="server" BackColor="#FFFFCC" ForeColor="Black" AutoGenerateColumns="False" Width="100%" >
<Columns>
<asp:BoundField DataField="line_id" HeaderText="Line Item"/>
<asp:BoundField DataField="no_of_participants" HeaderText="Number of Participants" />
<asp:BoundField DataField="amt_inventory" HeaderText="Current Inventory"/>
<asp:BoundField DataField="nsc_num" HeaderText="NSC number"/>
<asp:BoundField DataField="drug_name" HeaderText="Drug name"/>
<asp:BoundField DataField="dose_str" HeaderText="Dose Strength"/>
<asp:BoundField DataField="dose_unit" HeaderText="Dose Unit"/>
<asp:BoundField DataField="dose_form_comment" HeaderText="Dose Form"/>
<asp:BoundField DataField="dose_mult" HeaderText="Dose Mult" />
<asp:BoundField DataField="amt_req" HeaderText="Amt Required"/>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<asp:Button ID="btnClose" runat="server" Text="Close" />
</td>
</tr>
</table>
</asp:Panel>
<br />
</div>
<%
Response.AddHeader("Refresh", "60")
%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CIOSConnectionString3 %>"
SelectCommand="SELECT w.web_order_id, w.web_entry_date, w.site_num, w.protocol_num, w.inv_num, w.pharm_num, w.status, w.Comments, w.UserName, w.porStatus, p.Pharm_fname + ' ' + p.Pharm_lname AS 'PharmName' FROM Web_Shipping AS w INNER JOIN Pharmacist_of_record AS p ON p.pharm_num = w.pharm_num WHERE (w.status = #status) ORDER BY w.web_order_id DESC" >
<SelectParameters>
<asp:ControlParameter ControlID="OrderStatusDropDownList" Name="Status"
PropertyName="Text" Type="Char" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CIOSConnectionString3 %>"
SelectCommand="SELECT Web_Ship_detail.line_id, Web_Ship_detail.no_of_participants, Web_Ship_detail.Amt_inventory, Web_Ship_detail.NSC_num, Web_Ship_detail.Dose_str, Web_Ship_detail.Dose_unit, Web_Ship_detail.Dose_mult, Web_Ship_detail.amt_req, Drug.Drug_name, Dosage_Form.dose_form_comment FROM Web_Ship_detail INNER JOIN Drug ON Web_Ship_detail.NSC_num = Drug.NSC_Num INNER JOIN Dosage_Form ON Web_Ship_detail.Dose_form = Dosage_Form.dose_form WHERE (Web_Ship_detail.web_order_id = #web_order_id) ORDER BY Web_Ship_detail.line_id">
<SelectParameters>
<asp:ControlParameter ControlID="lblWebOrderID" Name="web_order_id"
PropertyName="Text" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
These
Eval("p.Pharm_fname"), Eval("p.Pharm_lname")
Do not exist in your select
p.Pharm_fname + ' ' + p.Pharm_lname AS 'PharmName'
You need to update either your Eval to evaluate PharmName or SQL to include p.Pharm_fname and p.Pharm_lname and get rid of the alias reference in the Eval.
I have an Update Panel which contains a GridView. 3 TextBoxes and a DropDownList control are Validated. I also have 3 different DDLs and 3 Checkbox controls in the panel that each trigger a rebind of the Gridview. When one of the un-validated DDLs or Checkboxes is changed they all fire the same changed event and I lose all of the Validation on the TextBoxes and the 1 DDL.
I'm a bit confused as to whether I should be setting Initial values on the validated or un-validated controls, if I should "group" the validation, and which set of controls needs to have the CausesValidation flag set. I hate to spam with massive amounts of code, but considering how much there is in this update panel....
<asp:UpdatePanel ID="UpdatePanel_Search" runat="server" >
<ContentTemplate>
<table class="auto-style2">
<tr>
<td>
<table class="auto-style1">
<tr>
<td class="auto-style3">
<div>
<table class="auto-style1" border="1px" frame="void">
<tr>
<td bgcolor="#00198D" style="text-align: center" class="auto-style19">
<asp:Label ID="FilterLabel3" runat="server" ForeColor="White" Text="Used by OEM"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style9">
<asp:Label ID="FilterLabel4" runat="server" ForeColor="White" Text="Item Type"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style24">
<asp:Label ID="FilterLabel5" runat="server" ForeColor="White" Text="Group Type"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style12">
<asp:Label ID="FilterLabel6" runat="server" ForeColor="White" Text="Part Active"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style17">
<asp:Label ID="FilterLabel7" runat="server" ForeColor="White" Text="Non-Inventory Part"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style7">
<asp:Label ID="FilterLabel8" runat="server" ForeColor="White" Text="Part In Stock"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style19">
<asp:DropDownList ID="DDL_OEM" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style9">
<asp:DropDownList ID="DDL_ItemTypes" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style9">
<asp:DropDownList ID="DDL_GroupTypes" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style12">
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Checked="True" Style="text-align: center" />
</td>
<td class="auto-style17">
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Style="text-align: center" />
</td>
<td class="auto-style7">
<asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Style="text-align: center" />
</td>
</tr>
</table>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox_Ticket_Search"
ErrorMessage="Ticket Number is Required. Enter NOTICKET if the item you are requesting is for your tech stock(i.e. a tool, USB drive, etc.)"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox_Part_Search"
ErrorMessage="Part Number is Required. Select a Part from the Catalog before submitting a request."
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="TextBox_Serial_Search"
ErrorMessage="System Serial Number is Required. Enter NOSERIAL if the item you are requesting is for your tech stock(i.e. a tool, USB drive, etc.)"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
ControlToValidate="DDL_OEM_submit0"
ErrorMessage="System Model is a required field. Please select a Model from the Drop Down below."
InitialValue="0"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
</td>
</tr>
<table class="auto-style1">
<tr>
<td class="auto-style34">
<table class="auto-style1">
<tr>
<td>
<asp:Label ID="Label_Comments_Search" runat="server" Text="Comments:"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: left">
<asp:TextBox runat="server"
ID="TextBox_Comments_Search"
TextMode="multiline"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalScrollBarVisibility="Visible" Height="100px" Width="300px">
</asp:TextBox>
</td>
</tr>
</table>
</td>
<td class="auto-style29">
<table class="auto-style1">
<tr>
<td class="auto-style4">
<asp:Label ID="Label_Ticket_Search" runat="server" Text="Ticket #:"></asp:Label>
</td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Ticket_Search" runat="server"></asp:TextBox>
<span class="auto-style23">*</span></td>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="Label_Part_Search" runat="server" Text="Part #:"></asp:Label>
</td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Part_Search" runat="server" ReadOnly="true" BackColor="#CCCCCC"></asp:TextBox>
<span class="auto-style23">*</span>
</td>
</tr>
<tr>
<td style="text-align: right" class="auto-style21">
<asp:Label ID="Label12" runat="server" Text="Serial #:"></asp:Label></td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Serial_Search" runat="server"></asp:TextBox>
<span class="auto-style23">*</span></td>
</tr>
<tr>
<td style="text-align: right" class="auto-style21">
<asp:Label ID="Label_Damage_Search" runat="server" Text="Part Damaged:"></asp:Label>
</td>
<td style="text-align: left" class="auto-style31">
<asp:CheckBox ID="CheckBox_Damage_Search" runat="server"></asp:CheckBox>
</td>
</tr>
</table>
</td>
<td>
<table class="auto-style25">
<tr>
<td>
<table class="auto-style25">
<tr>
<td>
<asp:Label ID="Label15" runat="server" Style="text-align: left" Text="Model:"></asp:Label>
</td>
<td align="left">
<asp:DropDownList ID="DDL_OEM_submit0" runat="server">
</asp:DropDownList>
<span class="auto-style23">*</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" Text="Submit Part Request" OnClick="Button2_Click" />
</td>
</tr>
</table>
</td>
<table class="auto-style1">
<tr>
<td>
<table class="auto-style1">
<tr>
<td class="auto-style8" valign="top">
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="SqlDataSource1"
EnableModelValidation="True"
AllowSorting="True"
OnSelectedIndexChanged="Gridview1_SelectedIndexChanged"
AutoGenerateSelectButton="True"
BackColor="White"
BorderColor="#999999"
BorderStyle="None"
BorderWidth="1px"
CellPadding="3"
GridLines="Vertical" HorizontalAlign="Justify">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#00198D" ForeColor="White" />
<PagerStyle ForeColor="Black" BackColor="#999999" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<EmptyDataTemplate>
No records could be retrieved from the database. We apologize for the inconvenience.
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="OEMPartCode" HeaderText="OEMPartCode" SortExpression="OEMPartCode" />
<asp:BoundField DataField="OEM" HeaderText="OEM" InsertVisible="False" ReadOnly="True" SortExpression="OEM" />
<asp:BoundField DataField="Sub Categories" HeaderText="Models" InsertVisible="False" ReadOnly="True" SortExpression="Sub Categories" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</td>
<td style="text-align: left" valign="top">
<asp:DetailsView
ID="DetailsView1"
runat="server"
DataSourceID="SqlDataSource2"
Height="50px"
Width="556px"
CellPadding="4"
AutoGenerateRows="False"
OnDataBound="DetailsView1_OnDataBound"
ForeColor="White"
EnableModelValidation="True"
DataKeyNames="ID"
HorizontalAlign="Left"
Style="margin-right: 0px">
<FieldHeaderStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="OEMPartCode" HeaderText="OEMPartCode" />
<asp:BoundField DataField="PartCode2" HeaderText="PartCode2" />
<asp:TemplateField HeaderText="UsedByOEM">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("UsedByOEM") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ItemType">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("JoinedItemType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="GroupType">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("JoinedGroupType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PartDesc" HeaderText="PartDescription" SortExpression="PartDesc" />
<asp:BoundField DataField="PartComment" HeaderText="PartComment" SortExpression="PartComment" />
<asp:BoundField DataField="PartCount" HeaderText="PartCount" SortExpression="PartCount" />
<asp:BoundField DataField="PartMin" HeaderText="PartMin" SortExpression="PartMin" />
<asp:CheckBoxField DataField="PartActive" HeaderText="PartActive" SortExpression="PartActive" />
<asp:BoundField DataField="MFRPartNumber" HeaderText="MFRPartNumber" SortExpression="MFRPartNumber" />
<asp:BoundField DataField="PartCapacity" HeaderText="PartCapacity" SortExpression="PartCapacity" />
<asp:CheckBoxField DataField="PreTurnRequired" HeaderText="PreTurnRequired" SortExpression="PreTurnRequired" />
<asp:TemplateField HeaderText="AssemblyPart">
<ItemTemplate>
<asp:Label ID="Label_AssemblyPart" runat="server" Text='<%# Bind("AssemblyPart") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Image">
<ItemTemplate>
<a href="javascript:void(window.open('<%# "ShowImage.aspx?PID="+ Eval("PartImage")%>','_blank','toolbar=no,menubar=no'))">
<asp:Image ID="FullImage" ToolTip="Click to download the full size image."
runat="server" ImageUrl='<%# "ShowThumb.aspx?size=120&PID="+ Eval("PartImage") %>' /></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Image 2">
<ItemTemplate>
<a href="javascript:void(window.open('<%# "ShowImage.aspx?PID="+ Eval("PartImage2")%>','_blank','toolbar=no,menubar=no'))">
<asp:Image ID="Image1" ToolTip="Click to download the full size image."
runat="server" ImageUrl='<%# "ShowThumb.aspx?size=120&PID="+ Eval("PartImage2") %>' /></a>
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="NonInventoryPart" HeaderText="NonInventoryPart" SortExpression="NonInventoryPart" />
<asp:TemplateField HeaderText="Updated By">
<ItemTemplate>
<asp:Label ID="UserNameLabel" runat="server" Text='<%# Bind("CreatedByUser") %>' ReadOnly="True"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Modified">
<ItemTemplate>
<asp:Label ID="ModifiedDateLabel" runat="server" Text='<%# Bind("LastModifiedDate") %>' ReadOnly="True"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Fields>
<FooterStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="Black" Width="300px" />
</asp:DetailsView>
</td>
</tr>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
DataSourceMode="DataSet"
SelectCommand="SELECT Stuff">
<FilterParameters>
<asp:ControlParameter Name="UsedByOEM" ControlID="DDL_OEM" PropertyName="SelectedValue" />
<asp:ControlParameter Name="ItemType" ControlID="DDL_ItemTypes" PropertyName="SelectedValue" />
<asp:ControlParameter Name="GroupType" ControlID="DDL_GroupTypes" PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>
<a></a>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT Stuff">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
Did you try giving the controls a group name?
Hi there I am trying to achieve the same functionality of the Example Hover menu over at http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx
However when my gridview display's and I mouse over the menu comes up but only for the entire gridview not each row like in the example ?. currently the menu buttons do nothing.
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="BookingsSQL"
ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" >
<Columns>
<asp:BoundField DataField="programme_name" HeaderText="programme_name"
SortExpression="programme_name" />
<asp:BoundField DataField="Start" HeaderText="Start" SortExpression="Start" />
<asp:BoundField DataField="Finish" HeaderText="Finish"
SortExpression="Finish" />
<asp:BoundField DataField="Source" HeaderText="Source"
SortExpression="Source" />
<asp:BoundField DataField="Destination" HeaderText="Destination"
SortExpression="Destination" />
<asp:BoundField DataField="Comment" HeaderText="Comment"
SortExpression="Comment" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="BookingsSQL" runat="server"
ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>"
SelectCommand="SELECT [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]">
</asp:SqlDataSource>
<asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server"
TargetControlID="GridView1"
PopupControlID="PopupMenu"
HoverCssClass="popupHover"
PopupPosition="Left"
OffsetX="0"
OffsetY="0"
PopDelay="50">
</asp:HoverMenuExtender>
<asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server"
CommandName="Delete" Text="Delete" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Tried a few different ways using jquery hover but this would be the best solution.
Any help please . Thanks.
There is solution.
It's not so tricky to implement a HoverExtender for each row since this showed in sample toolkit sample, as to provide columns headers with sorting.
Draw attention that there is surrogate primary key added to Bookings table for allowing editing all fields values. Also there is used jQuery datepicker plugin for editing Start and Finish fields values. You may use DatePickerExtender from the AjaxControlToolkit instead, but in that case those extenders as well as the HoverExtenders must be added for each row in grid separately.
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="BookingsSQL"
ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="ID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table runat="server" visible="<%# Container.DataItemIndex == 0 %>">
<tr>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
Programme Name
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
Start
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
Finish
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
Source
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
Destination
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
Comment
</asp:LinkButton>
</th>
</tr>
</table>
<asp:Panel runat="server" ID="ItemContainer">
<table width="100%">
<tr>
<td width="20%">
<%# Eval("programme_name") %>
</td>
<td width="20%">
<%# Eval("Start", "{0:dd/MM/yyyy}") %>
</td>
<td width="20%">
<%# Eval("Finish", "{0:dd/MM/yyyy}") %>
</td>
<td width="20%">
<%# Eval("Source") %>
</td>
<td width="20%">
<%# Eval("Destination") %>
</td>
<td width="20%">
<%# Eval("Comment") %>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete" />
</asp:Panel>
<ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
</ajaxToolkit:HoverMenuExtender>
</ItemTemplate>
<EditItemTemplate>
<table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
<tr>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
Programme Name
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
Start
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
Finish
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
Source
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
Destination
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
Comment
</asp:LinkButton>
</th>
</tr>
</table>
<asp:Panel runat="server" ID="ItemContainer">
<asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("ID") %>' />
<table width="100%">
<tr>
<td width="20%">
<asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("programme_name") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("Start", "{0:dd/MM/yyyy}") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Finish", "{0:dd/MM/yyyy}") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Source") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Destination") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Comment") %>' />
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
Text="Update" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
Text="Cancel" />
</asp:Panel>
<ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
</ajaxToolkit:HoverMenuExtender>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="BookingsSQL" runat="server" ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>"
OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
SelectCommand="SELECT [ID], [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]"
DeleteCommand="DELETE FROM [Bookings] WHERE [programme name] = #ID" InsertCommand="INSERT INTO [Bookings] ([programme name], [Start], [Finish], [Source], [Destination], [Comment]) VALUES (#programme_name, #Start, #Finish, #Source, #Destination, #Comment)"
UpdateCommand="UPDATE [Bookings] SET [programme name] = #programme_name, [Start] = #Start, [Finish] = #Finish, [Source] = #Source, [Destination] = #Destination, [Comment] = #Comment WHERE [ID] = #ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="programme_name" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="Finish" Type="DateTime" />
<asp:Parameter Name="Source" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Comment" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="Finish" Type="DateTime" />
<asp:Parameter Name="Source" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Comment" Type="String" />
<asp:Parameter Name="programme_name" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks for such a great help... its working for me i have used SqlDataSource instead of using objectDataSource...
here is my running code that is working great for me....
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="PageAddID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
<tr>
<th width="20%">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="PageName">
Page Name
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Sort" CommandArgument="PageTitle">
PageTitle
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
Metakeyword
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="Sort" CommandArgument="Description">
Description
</asp:LinkButton>
</th>
</tr>
</table>
<asp:Panel runat="server" ID="ItemContainer">
<table width="100%">
<tr>
<td width="20%">
<%# Eval("PageName") %>
</td>
<td width="20%">
<%# Eval("PageTitle") %>
</td>
<td width="20%">
<%# Eval("Metakeyword") %>
</td>
<td width="20%">
<%# Eval("Description") %>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
<asp:LinkButton ID="LinkButton5" runat="server" CommandName="Edit" Text="Edit" />
<br />
<asp:LinkButton ID="LinkButton6" runat="server" CommandName="Delete" Text="Delete" />
</asp:Panel>
<ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
</ajaxToolkit:HoverMenuExtender>
</ItemTemplate>
<EditItemTemplate>
<table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
<tr>
<th width="20%">
<asp:LinkButton ID="LinkButton7" runat="server" CommandName="Sort" CommandArgument="PageName">
Page Name
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton8" runat="server" CommandName="Sort" CommandArgument="PageTitle">
PageTitle
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton9" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
Metakeyword
</asp:LinkButton>
</th>
<th width="20%">
<asp:LinkButton ID="LinkButton10" runat="server" CommandName="Sort" CommandArgument="Description">
Description
</asp:LinkButton>
</th>
</tr>
</table>
<asp:Panel runat="server" ID="ItemContainer">
<asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("PageAddID") %>' />
<table width="100%">
<tr>
<td width="20%">
<asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("PageName") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("PageTitle") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Metakeyword") %>' />
</td>
<td width="20%">
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Description") %>' />
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
Text="Update" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
Text="Cancel" />
</asp:Panel>
<ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender2" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
</ajaxToolkit:HoverMenuExtender>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
"
OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
SelectCommand="SELECT * FROM [AddPages]"
DeleteCommand="DELETE FROM [AddPages] WHERE [PageAddId] = #PageAddID"
UpdateCommand="UPDATE [AddPages] SET [PageName] = #PageName, [PageTitle] = #PageTitle, [Metakeyword] = #Metakeyword, [Description] = #Description WHERE [PageAddID] = #PageAddID">
<DeleteParameters>
<asp:Parameter Name="PageAddID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="PageName" Type="string" />
<asp:Parameter Name="PageTitle" Type="string" />
<asp:Parameter Name="Metakeyword" Type="string" />
<asp:Parameter Name="Description" Type="string" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="PageAddID" Type="Int32" />
<asp:Parameter Name="PageName" Type="string" />
<asp:Parameter Name="PageTitle" Type="string" />
<asp:Parameter Name="Metakeyword" Type="string" />
<asp:Parameter Name="Description" Type="string" />
</UpdateParameters>
</ContentTemplate>
</asp:UpdatePanel>
I have created 2 dropdownlists that are binded to a SQL DB and then pulling up a GridView. But, more specifically is there a way to have 3 user picked boxes and then have a Gridview show up? I would like to have a quick efficient way to do this without problems. I created the first 2 DDLs with autopostback and not working properly. any suggestions?
<asp:Label ID="CustomerNumberLabel" runat="server" Text="Customer Number " Width="125px"></asp:Label>
<asp:DropDownList ID="CustomerNumber" runat="server" AutoPostBack="True"
DataSourceID="ADDRDataSource" DataTextField="SACSNO"
DataValueField="SACSNO" AppendDataBoundItems="True">
<asp:ListItem Text="Select a Customer" Value="" Selected="True" />
</asp:DropDownList><br />
<asp:SqlDataSource ID="ADDRDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>"
SelectCommand="SELECT [SACSNO] FROM [ADDR] WHERE ([SARP#1] = #column1)">
<SelectParameters>
<asp:SessionParameter Name="column1" SessionField="userName" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Label ID="ShipToNumberLabel" runat="server" Text="Ship-to Location " Width="125px"></asp:Label>
<asp:DropDownList ID="ShipToNumber" runat="server"
DataSourceID="ADDRShipToNumberDataSource" DataTextField="SASHNM"
DataValueField="SASHNM" AutoPostBack="True">
<asp:ListItem Text="Select Ship-To Location" Value="" Selected="True" />
</asp:DropDownList>
<asp:SqlDataSource ID="ADDRShipToNumberDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>"
SelectCommand="SELECT [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SACSNO], [SASHST], [SASZIP] FROM [ADDR] WHERE ([SACSNO] = #SACSNO)">
<SelectParameters>
<asp:ControlParameter ControlID="CustomerNumber" Name="SACSNO"
PropertyName="SelectedValue" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
<br /><br />
<asp:FormView ID="FormView1" runat="server"
DataSourceID="ADDRShippingDataSource" Width="400px">
<EditItemTemplate>
SACSNO:
<asp:TextBox ID="SACSNOTextBox" runat="server" Text='<%# Bind("SACSNO") %>' />
<br />
SASHNM:
<asp:TextBox ID="SASHNMTextBox" runat="server" Text='<%# Bind("SASHNM") %>' />
<br />
SASAD1:
<asp:TextBox ID="SASAD1TextBox" runat="server" Text='<%# Bind("SASAD1") %>' />
<br />
SASAD2:
<asp:TextBox ID="SASAD2TextBox" runat="server" Text='<%# Bind("SASAD2") %>' />
<br />
SASCTY:
<asp:TextBox ID="SASCTYTextBox" runat="server" Text='<%# Bind("SASCTY") %>' />
<br />
SASHST:
<asp:TextBox ID="SASHSTTextBox" runat="server" Text='<%# Bind("SASHST") %>' />
<br />
SASZIP:
<asp:TextBox ID="SASZIPTextBox" runat="server" Text='<%# Bind("SASZIP") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
SACSNO:
<asp:TextBox ID="SACSNOTextBox" runat="server" Text='<%# Bind("SACSNO") %>' />
<br />
SASHNM:
<asp:TextBox ID="SASHNMTextBox" runat="server" Text='<%# Bind("SASHNM") %>' />
<br />
SASAD1:
<asp:TextBox ID="SASAD1TextBox" runat="server" Text='<%# Bind("SASAD1") %>' />
<br />
SASAD2:
<asp:TextBox ID="SASAD2TextBox" runat="server" Text='<%# Bind("SASAD2") %>' />
<br />
SASCTY:
<asp:TextBox ID="SASCTYTextBox" runat="server" Text='<%# Bind("SASCTY") %>' />
<br />
SASHST:
<asp:TextBox ID="SASHSTTextBox" runat="server" Text='<%# Bind("SASHST") %>' />
<br />
SASZIP:
<asp:TextBox ID="SASZIPTextBox" runat="server" Text='<%# Bind("SASZIP") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Customer Detail<br />
<br />
<table class="style1" width="35px">
<tr>
<td class="style2" align="center" >
Address Line 1</td>
<td class="style3" align="center" >
<asp:Label ID="SASAD1Label" runat="server" Text='<%# Bind("SASAD1") %>' />
</td>
</tr>
<tr>
<td class="style2" align="center" >
Address Line 2</td>
<td class="style3" align="center" >
<asp:Label ID="SASAD2Label" runat="server" Text='<%# Bind("SASAD2") %>' />
</td>
</tr>
<tr>
<td class="style2" align="center">
City</td>
<td class="style3" align="center" >
<asp:Label ID="SASCTYLabel" runat="server" Text='<%# Bind("SASCTY") %>' />
</td>
</tr>
<tr>
<td align="center" class="style2">
State</td>
<td class="style3" align="center" >
<asp:Label ID="SASHSTLabel" runat="server" Text='<%# Bind("SASHST") %>' />
</td>
</tr>
<tr>
<td align="center" class="style2">
Zip</td>
<td class="style3" align="center" >
<asp:Label ID="SASZIPLabel" runat="server" Text='<%# Bind("SASZIP") %>' />
</td>
</tr>
</table>
<br />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="ADDRShippingDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:iSeriesHistoryConnectionString %>"
SelectCommand="SELECT [SACSNO], [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SASHST], [SASZIP] FROM [ADDR] WHERE ([SASHNM] = #SASHNM)">
<SelectParameters>
<asp:ControlParameter ControlID="ShipToNumber" Name="SASHNM"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
You can turn off AutoPostBack for all the DropDownLists, and add a Button called Lookup with something like the following in the Lookup Button_Click event:
ADDRShippingDataSource.SelectParameters.Clear()
If ShipToNumber.SelectedValue <> "" Then
ADDRShippingDataSource.SelectParameters.Add("SASHNM", ShipToNumber.SelectedValue)
End If
If CustomerNumber.SelectedValue <> "" Then
ADDRShippingDataSource.SelectParameters.Add("SACSNO", CustomerNumber.SelectedValue)
End If
ADDRShippingDataSource.DataBind()
Your select command would need to be updated to include the additional criteria in your DataSource:
SELECT [SACSNO], [SASHNM], [SASAD1], [SASAD2], [SASCTY], [SASHST], [SASZIP] FROM [ADDR] WHERE (#SASHNM IS NULL OR [SASHNM] = #SASHNM) OR (#SACSNO IS NULL OR [SACSNO] = #SACSNO)