I have been searching the web for hours trying to figure out what is causing this exception, I feel like I am missing something...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" DataKeyNames="ProductID"
DataSourceID="SqlDataSource1"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID"
SortExpression="CategoryID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title"
/>
<asp:BoundField DataField="ShortDescription" HeaderText="ShortDescription"
SortExpression="ShortDescription" />
<asp:BoundField DataField="LongDescription" HeaderText="LongDescription"
SortExpression="LongDescription" />
<asp:BoundField DataField="ImageUrl" HeaderText="ImageUrl"
SortExpression="ImageUrl" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price"
/>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="Title" DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:s3435926ConnectionString %>"
SelectCommand="SELECT [CategoryID], [Title] FROM [Category]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:s3435926ConnectionString %>"
SelectCommand="SelectProductsWithParam" SelectCommandType="StoredProcedure"
UpdateCommand="UpdateProdsWithParam" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameter FormField="DropDownList1" Name="prodID" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="prodID" Type="Int32" />
<asp:Parameter Name="CatID" Type="Int32" />
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="Sdesc" Type="String" />
<asp:Parameter Name="Ldesc" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="price" Type="Decimal" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
</form>
</body>
</html>
The SP is
[dbo].[UpdateProdsWithParam] #prodID int, #CatID int, #title nvarchar(50),
#Sdesc nvarchar(100), #Ldesc nvarchar(200),
#url nvarchar(50), #price money
AS
UPDATE Product
SET CategoryID = #CatID, Title = #title,
ShortDescription = #Sdesc, LongDescription = #Ldesc,
ImageUrl = #url, Price = #price
WHERE ProductID = #prodID
I am getting 'Procedure or Function has too many parameters specified'
Any suggestions?
Share your C# code. Error clearly says that you are passing too many parameters. Check out your parameters count & parameters name.
Related
I would like the header frozen at the top because i have over 9000 rows. I have tried "fixed" but that doesn't look the best. It was fixed in place on scroll but looked like it was floating in place. What can i do to get the top frozen? I tried a css style but it wasn't freezing the header either. If i can get the header frozen the next step is to freeze the footer on screen also so new entries can be made without having to go to the bottom on 9000 rows.
<asp:GridView id="myGridView" runat="server" AutoGenerateColumns="False"
CssClass="Grid"
Overflow="auto"
AllowSorting="False"
CellPadding="4"
ForeColor="#333333"
GridLines="None"
ShowFooter="True"
DataKeyNames="RMANumber" width="99%">
<AlternatingRowStyle BackColor="LightGray" />
<Columns>
<asp:TemplateField HeaderText="RMA Number" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblRMANumber" runat="server" ReadOnly="false" Text='<%# DataBinder.Eval(Container, "DataItem.RMANumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditRMANumber" size="16" runat="server" ReadOnly="false" Text='<%# DataBinder.Eval(Container, "DataItem.RMANumber") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddRMANumber" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Decon Form? Y/N" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblDeconForm" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DeconForm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditDeconForm" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DeconForm") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddDeconForm" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblCustomer" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Customer") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditCustomer" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Customer") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddCustomer" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Problem / Solution Found" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblProblemSolutionFound" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ProblemSolutionFound") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditProblemSolutionFound" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ProblemSolutionFound") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddProblemSolutionFound" size="16" runat="server"></asp:TextBox>
<asp:Button id="btnAdd" runat="server" Text="Add" CommandName="Add" AutoPostBack="False" ></asp:Button>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" CancelText="Cancel" DeleteText="Delete" EditText="Edit" UpdateText="Update" HeaderText="Modify"
ShowDeleteButton="False" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left"
ButtonType="Image" CancelImageUrl="Images/Cancel.png" EditImageUrl="Images/Edit.png" UpdateImageUrl="Images/Update.png" ControlStyle-Width="60" ControlStyle-Height="20"/>
<asp:TemplateField HeaderText="Delete" ShowHeader="true" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left" >
<ItemTemplate>
<asp:ImageButton ID="DeleteButton" runat="server" ImageUrl="Images/Delete.png" Width="60" Height="20" VerticalAlign="Center"
CommandName="Delete"
AlternateText="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#ADD8E6" />
<FooterStyle BackColor="#ADD8E6" 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>
To keep the header at the top i used a script to duplicate the header and put it in it's own container. But I still had issues with the footer being visible. I decided to make a create button in a new page instead of dealing with the footer. It is much more cleaner for the user inputting data into a form instead of gridview footer. In the same fashion i use the edit record button to open the record in a new page for updating / editing it. I also made the gridview page sort by desc to only see the most recent RMAs, removed the duplicate header script, and used paging. no reason to see all the records, just the most recent.
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True"
PageSize="10"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="RMANumber"
CellPadding="1"
ForeColor="#333333"
DataSourceID="SqlDataSource1">
<AlternatingRowStyle BackColor="LightGray" />
<Columns>
<asp:CommandField ShowDeleteButton="False" ShowEditButton="True" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left"
ButtonType="Image" CancelImageUrl="Images/Cancel.png"
EditImageUrl="Images/Edit.png" UpdateImageUrl="Images/Update.png"
ControlStyle-Width="60" ControlStyle-Height="20">
<ControlStyle Height="20px" Width="60px"></ControlStyle>
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle"></HeaderStyle>
</asp:CommandField>
<asp:Boundfield DataField="RMANumber" HeaderText="RMA Number" ReadOnly="True" SortExpression="RMANumber" > <ItemStyle Width="5%" /> </asp:Boundfield>
<asp:BoundField DataField="DconForm" HeaderText="Dcon Form" SortExpression="DconForm" > <ItemStyle Width="3%" /> </asp:BoundField>
<asp:BoundField DataField="Customer" HeaderText="Customer" SortExpression="Customer" > <ItemStyle Width="10%" /> </asp:BoundField>
<asp:BoundField DataField="ItemBeingReturned" HeaderText="Item(s) Being Returned" SortExpression="ItemBeingReturned" > <ItemStyle Width="10%" /> </asp:BoundField>
<asp:BoundField DataField="ReasonForReturn" HeaderText="Reason For Return" SortExpression="ReasonForReturn" > <ItemStyle Width="15%" /> </asp:BoundField>
<asp:BoundField DataField="Dia" HeaderText="Dia" SortExpression="Dia" > <ItemStyle Width="7%" /> </asp:BoundField>
<asp:BoundField DataField="RMADate" HeaderText="RMA Date" SortExpression="RMADate" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="ReturnedDate" HeaderText="Returned Date" SortExpression="ReturnedDate" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="DateShipped" HeaderText="Date Shipped" SortExpression="DateShipped" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="PIKEContact" HeaderText="PIKE Contact" SortExpression="PIKEContact" > <ItemStyle Width="7%" /> </asp:BoundField>
<asp:BoundField DataField="DiamondResults" HeaderText="Diamond Results" SortExpression="DiamondResults" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="ProblemSolutionFound" HeaderText="Problem / Solution Found" SortExpression="ProblemSolutionFound" > <ItemStyle Width="15%" /> </asp:BoundField>
<asp:TemplateField HeaderText="" ShowHeader="true" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left" >
<ItemTemplate>
<asp:ImageButton ID="DeleteButton" runat="server" ImageUrl="Images/Delete.png" Width="60" Height="20" VerticalAlign="Center"
CommandName="Delete"
AlternateText="Delete" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle"></HeaderStyle>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#ADD8E6" />
<FooterStyle BackColor="#ADD8E6" 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>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PIKE_Intranet_DBConnectionString %>"
DeleteCommand="DELETE FROM [RMATable] WHERE [RMANumber] = #RMANumber"
InsertCommand="INSERT INTO [RMATable] ([RMANumber], [DconForm], [Customer], [ItemBeingReturned], [ReasonForReturn], [Dia], [RMADate], [ReturnedDate], [DateShipped], [Status], [PIKEContact], [DiamondResults], [ProblemSolutionFound]) VALUES (#RMANumber, #DconForm, #Customer, #ItemBeingReturned, #ReasonForReturn, #Dia, #RMADate, #ReturnedDate, #DateShipped, #Status, #PIKEContact, #DiamondResults, #ProblemSolutionFound)"
SelectCommand="SELECT * FROM [RMATable] ORDER BY [RMANumber] DESC"
UpdateCommand="UPDATE [RMATable] SET [DconForm] = #DconForm, [Customer] = #Customer, [ItemBeingReturned] = #ItemBeingReturned, [ReasonForReturn] = #ReasonForReturn, [Dia] = #Dia, [RMADate] = #RMADate, [ReturnedDate] = #ReturnedDate, [DateShipped] = #DateShipped, [Status] = #Status, [PIKEContact] = #PIKEContact, [DiamondResults] = #DiamondResults, [ProblemSolutionFound] = #ProblemSolutionFound WHERE [RMANumber] = #RMANumber">
<DeleteParameters>
<asp:Parameter Name="RMANumber" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="RMANumber" Type="String" />
<asp:Parameter Name="DconForm" Type="String" />
<asp:Parameter Name="Customer" Type="String" />
<asp:Parameter Name="ItemBeingReturned" Type="String" />
<asp:Parameter Name="ReasonForReturn" Type="String" />
<asp:Parameter Name="Dia" Type="String" />
<asp:Parameter Name="RMADate" Type="String" />
<asp:Parameter Name="ReturnedDate" Type="String" />
<asp:Parameter Name="DateShipped" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="PIKEContact" Type="String" />
<asp:Parameter Name="DiamondResults" Type="String" />
<asp:Parameter Name="ProblemSolutionFound" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="DconForm" Type="String" />
<asp:Parameter Name="Customer" Type="String" />
<asp:Parameter Name="ItemBeingReturned" Type="String" />
<asp:Parameter Name="ReasonForReturn" Type="String" />
<asp:Parameter Name="Dia" Type="String" />
<asp:Parameter Name="RMADate" Type="String" />
<asp:Parameter Name="ReturnedDate" Type="String" />
<asp:Parameter Name="DateShipped" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="PIKEContact" Type="String" />
<asp:Parameter Name="DiamondResults" Type="String" />
<asp:Parameter Name="ProblemSolutionFound" Type="String" />
<asp:Parameter Name="RMANumber" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
</div>
</form>
I am currently tasked to do a SQL database with web interface. I am using the Microsoft Visual Web Developer 2010 Express to develop the prototype.
My question is, using the detailsview to edit the user information, how do I make the editable text box to be extended to the end of the table? If possible, the text box can extend downwards with excess text wrapped.
The picture here shows my current output.
Here is my code...
<%# Page Title="Display Staff Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="DisplayStaff.aspx.cs" Inherits="ASCBioData.About" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Display Staff Biography
</h2>
<p>
Staff:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="ObjectDataSource1" DataTextField="Name" DataValueField="ID">
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="ASCBioData.Data.StaffDataTableAdapters.ASCBioDataTableAdapter">
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Education" Type="String" />
<asp:Parameter Name="BIO" Type="String" />
<asp:Parameter Name="Highlights" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:DetailsView ID="StaffTable" runat="server" AutoGenerateRows="False"
CellPadding="10" DataSourceID="ObjectDataSource2" ForeColor="#333333"
GridLines="None" Height="50px" Width="916px">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" HorizontalAlign="Right" />
<EditRowStyle BackColor="#8E8064" Wrap="True" />
<FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" VerticalAlign="Top"
Width="70px" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" Visible="False" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Education" HeaderText="Education"
SortExpression="Education" />
<asp:BoundField DataField="BIO" HeaderText="BIO" SortExpression="BIO" />
<asp:BoundField DataField="Highlights" HeaderText="Highlights"
SortExpression="Highlights" />
<asp:CommandField ShowEditButton="True" />
</Fields>
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<InsertRowStyle Height="300px" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetDataByID"
TypeName="ASCBioData.Data.StaffDataTableAdapters.ASCBioDataTableAdapter"
UpdateMethod="UpdateStaffData">
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Education" Type="String" />
<asp:Parameter Name="BIO" Type="String" />
<asp:Parameter Name="Highlights" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="IsID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Education" Type="String" />
<asp:Parameter Name="BIO" Type="String" />
<asp:Parameter Name="Highlights" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
</p>
</asp:Content>
Please advise and thanks in advance...
you can use <asp:TemplateField /> then inside you can use <asp:TextBox /> and set TextMode="MultiLine". So something like
<asp:TemplateField>
<ItemTemplate>
<%# Eval("Highlights") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Highlights") %>'
TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
This is on top of my head so do test the syntax.. but it should give you what you're looking for.
I've created a page that spits out data from a table. I've gotten the update and delete functionality, but I'm having trouble figuring out how to search and add values. I threw in a few text boxes to mess around with, but I don't know how to make them into controls. I'd like to be able to search the data, as well as enter new data. How do I make these text boxes into search controls for the grid? Also how do I use text boxes or drop down boxes to insert new values into the table?
Here is what I have so far:
<%# Page Title="Bank Statements" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BankStatements.aspx.vb" Inherits="Compliance.BankStatements" %>
<script runat="server">
Protected Sub Page_Load(sender As Object, e As EventArgs)
End Sub
</script>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<hgroup class="title">
<h1><%: Title %>.</h1>
<h2>Enter View and Edit Bank Statments Here<br />
</h2>
</hgroup>
<br />
Franchise ID:
<asp:TextBox ID="TextBox1" runat="server" Width="95px"></asp:TextBox>
Year:
<asp:TextBox ID="TextBox2" runat="server" Width="56px"></asp:TextBox>
Month:
<asp:TextBox ID="TextBox3" runat="server" Width="65px"></asp:TextBox>
<asp:GridView
ID="GridView1"
runat="server"
AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
ForeColor="#333333"
GridLines="None"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
EnableSortingAndPagingCallbacks="True"
AllowPaging="True"
>
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="FranchiseID" HeaderText="FranchiseID" SortExpression="FranchiseID" />
<asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
<asp:BoundField DataField="Month" HeaderText="Month" SortExpression="Month" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:BoundField DataField="DatePosted" HeaderText="DatePosted" SortExpression="DatePosted" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<hgroup>
</hgroup>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ComplianceConnectionString1 %>"
SelectCommand=
"SELECT FranchiseID, Year, Month, Amount, DatePosted, id FROM BankStmts ORDER BY DatePosted DESC"
DeleteCommand=
"DELETE
FROM [BankStmts]
WHERE id = #id"
UpdateCommand=
"UPDATE [BankStmts]
SET FranchiseID = #FranchiseID, Year = #Year, Month = #Month, Amount = #Amount, DatePosted = #DatePosted
WHERE id = #id"
InsertCommand=
"Insert INTO [BankStmts] FranchiseID, Year, Month, Amount, DatePosted
VALUES #FranchiseID, #Year, #Month, #Amount, #DatePosted"
>
<DeleteParameters>
<asp:Parameter Name="id" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="FranchiseID" />
<asp:Parameter Name="Year" />
<asp:Parameter Name="Month" />
<asp:Parameter Name="Amount" />
<asp:Parameter Name="DatePosted" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FranchiseID" />
<asp:Parameter Name="Year" />
<asp:Parameter Name="Month" />
<asp:Parameter Name="Amount" />
<asp:Parameter Name="DatePosted" />
<asp:Parameter Name="id" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>
I have a submit button that inserts user entered data into a database. It was working perfectly fine until I migrated the project to the host server. The select query is still functional and displaying my data in the GridView (I checked by manually inserting some data into the database on the host server), I am unable to insert or delete data via the client-side page. It's an access database and I am connecting to it using the Visual Studio AccessDataSource.
Also, I don't receive any errors when loading the page or when I hit submit, its just that nothing happens.
Here is my code:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="jotest.aspx.vb" Inherits="jotest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
<!--
function imposeMaxLength(Object, MaxLen) {
return (Object.value.length <= MaxLen);
}
-->
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/login.mdb"
DeleteCommand="DELETE FROM tblComments WHERE ID = #ID"
InsertCommand="INSERT INTO tblComments(comment, commentor_name, comment_date) VALUES (#comment, #commentor_name, #comment_date)"
SelectCommand="SELECT ID, commentor_name, comment, comment_date FROM tblComments">
<InsertParameters>
<asp:Parameter Name="commentor_name" />
<asp:Parameter Name="comment" />
<asp:Parameter Name="comment_date" />
<asp:Parameter Name="ID" />
</InsertParameters>
<DeleteParameters>
<asp:Parameter Name="ID" />
</DeleteParameters>
</asp:AccessDataSource>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="position: absolute; top: 50px; left: 600px;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="comment" HeaderText="Name" SortExpression="comment" ItemStyle-Width="80px" />
<asp:BoundField DataField="commentor_name" HeaderText="Comment" SortExpression="commentor_name" ItemStyle-Width="300px" />
<asp:BoundField DataField="comment_date" HeaderText="Date" SortExpression="date" ItemStyle-Width="175px" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</div>
<br />
<asp:FormView ID="FormView1" runat="server" DataSourceID="AccessDataSource1" DefaultMode="Insert">
<InsertItemTemplate>
Name:<asp:TextBox ID="commentor_nameTextBox" runat="server" Text='<%# Bind("commentor_name") %>'></asp:TextBox>
<br />
Comment:<asp:TextBox ID="txtComments" runat="server" onkeypress="return imposeMaxLength(this, 150);" Text='<%# Bind("comment") %>' TextMode="MultiLine" Rows="4" Columns="50"></asp:TextBox>
<br />
<asp:HiddenField ID="hidTimeDate" runat="server" Value='<%# Bind("comment_date") %>' />
<asp:Button ID="butSubmit" runat="server" CommandName="Insert" Text="Submit" />
</InsertItemTemplate>
</asp:FormView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Make sure the account that is accessing the file has read and write access on the host server folder where the mdb file is located.
I am trying to perform a search query using drop down boxes with a button named search. I want it to bring up the data that is searched for. I dont know where to start from, i have looked around for some coding and different ways to do it but they seem complicated, this is the bit of ASP that is my weakness, need some assistance and guidance. below is the code for the page;
<%# Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ForSale.aspx.vb" Inherits="Users_ForSale" title="Properties For Sale" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h3>Properties For Sale</h3>
<h5>
<asp:Label ID="lblTown" runat="server" Text="Town:"></asp:Label>
<asp:DropDownList ID="ddlTownSearch" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Chadderton</asp:ListItem>
<asp:ListItem Value="Failsworth"></asp:ListItem>
<asp:ListItem>Oldham</asp:ListItem>
<asp:ListItem>Royton</asp:ListItem>
<asp:ListItem>Shaw</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblBedroomsSearch" runat="server" Text="Bedrooms:"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6+</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblMinPrice" runat="server" Text="Min Price (£):"></asp:Label>
<asp:TextBox ID="txtMinPriceSearch" runat="server" Width="87px"></asp:TextBox>
<asp:Label ID="lblMaxPriceSearch" runat="server" style="text-align: left"
Text="Max Price (£):"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="87px"></asp:TextBox>
</h5>
<h5>
<asp:Button ID="btnForsaleSearch" runat="server" Text="Search" />
</h5>
<p>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="ProductId" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None" Width="588px">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:ImageField DataImageUrlField="ImageURL">
</asp:ImageField>
<asp:BoundField DataField="ProductId" HeaderText="ProductId" ReadOnly="True"
SortExpression="ProductId" />
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Town" HeaderText="Town"
SortExpression="Town" />
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:JPEstatesConnectionString %>"
SelectCommand="SELECT * FROM [Products]"
DeleteCommand="DELETE FROM [Products] WHERE [ProductId] = #ProductId"
InsertCommand="INSERT INTO [Products] ([ProductId], [Description], [Price], [Category], [ImageURL]) VALUES (#ProductId, #Description, #Price, #Category, #ImageURL)"
UpdateCommand="UPDATE [Products] SET [Description] = #Description, [Price] = #Price, [Category] = #Category, [ImageURL] = #ImageURL WHERE [ProductId] = #ProductId">
<DeleteParameters>
<asp:Parameter Name="ProductId" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Category" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
<asp:Parameter Name="ProductId" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProductId" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Category" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
It depends on your strategy, if you want to search with EXACTLY same matches your search query will be like this:
SELECT * FROM [Products] WHERE [ProductId]=#ProductID AND [Price]=#Price AND...and other conditions that you need.
and if you like to retrieve similar results you have to use LIKE instead of '=' like this one:
SELECT * FROM [Products] WHERE [ProductId] LIKE '%' + #ProductId+ '%' AND ([Price] BETWEEN #Price1 AND #Price2) AND...and other conditions
Price1 and Price2 can be range of user input price
It helps you for using ASP.NET SQLParameters with LIKE statement