How can i rotate gridview on page? - c#

I want to rotate gridview in Web Form to print it clear because it doesn't fit in portrait orientation of the page. Gridview is going after page-break-before:always;
But when I rotate it, it cuts 50% of the grid for some strange reasons.
How can I rotate grid and make it fit 100% on the page ?
I want to have something like this :
But i have this situation
My CSS to rotate :
.gridCss {
width: 100%;
-ms-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-o-transform: rotate(90deg);
font-size:8px;
word-wrap: break-word;
height:100%;
}
My code:
<div class="gridCss" style="page-break-before:always;" >
<br />
<br />
<center CssClass="rotateText" > <asp:Label ID="MainLbl" runat="server" /> и</center> <br />
<center CssClass="rotateText" ><asp:Label ID="Lab1" runat="server" Text=""></asp:Label></center> <br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="DSI" Width="100%" >
<Columns>
<asp:BoundField DataField="one" HeaderText="" SortExpression="1" HtmlEncode="True" />
<asp:BoundField DataField="fio" HeaderText="two" SortExpression="2" />
<asp:BoundField DataField="3" HeaderText="" SortExpression="3" />
<asp:BoundField DataField="4" HeaderText="К4" SortExpression="4" />
<asp:BoundField DataField="Date" HeaderText="5" SortExpression="Date" />
...
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="DSI" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectSta %>" SelectCommand="Command" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="Sess" SessionField="Sess" Type="String" />
<asp:Parameter DefaultValue="1" Name="st" Type="Int32" />
<asp:Parameter DefaultValue="1" Name="nr" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
<tr>
<td class="abz"/>
<td align="right">
<pre>
_______
<asp:Label ID="Label_gv_2" runat="server" Text="_____"></asp:Label>
_______ __________________ Дата:___
<asp:Label ID="Label_dt_2" runat="server" Text="_____"></asp:Label>
________ (ФИО) (подпись)<br />
</pre>
</div>

I used DevExpress Data Grid that supports export and printing with extended options, including document page orientation. If you do not need the grid, you can use their reporting tool to print tabled data.

Related

To show ProgressBar onclick of Button inside GridView

I have a GridView in which the last Column has a Button which loads data.
Doing that takes like 2 Minutes.So, I need the user to know that some functions are going on in backend not that the screen is frozen
So,I need to show a ProgressBar on click of that button inside the GridView
How to do that??
I was searching for this for a while finally found it ,
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="Gridview" OnRowDataBound="Gridview_RowDataBound" OnRowCommand="Gridview_RowCommand" runat="server" Style="text-align: center" ShowFooter="true" Width="99%"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Total Customers" HeaderStyle-BackColor="#99CCCC">
<ItemTemplate>
<asp:Button ID="btnCombine" CssClass="btn-primary btn" Text="Combine"
Font-Bold="true"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="More"
Style="padding-top: 1%; padding-bottom: 1%; margin-top: 1px; margin-bottom: 1px" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
<ProgressTemplate>
<img src="images/progress_bar.gif" style="max-width: 250px" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddi" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
just name the same ID of the button u use in controlID of the AsyncPostBackTrigger and AssociatedUpdatePanelID same name u put the GridView

Is this a bug or a complex coding solution with GridView formatting in edit mode?

I'm in the process of trying to determing if what I'm seeing is solvable via code or is a bug in GridView (Using Visual Studio 2012 Preimum/SQL Server 2012 - Patched to Current Standards with .NET 4.5 (4.0 used in code)). Using Microsoft's AdventureWorks2012 for dB information.
I have a GridView that sits inside of a panel (the SQL Data is solid and works as I want it) which has a Frozen Header (with all the column names from the database). When the page loads, everything behaves as I want it. However, when I go into edit mode the formatting that I set in non editing mode is gone and the panel that holds the GridView doesn't stretch out to fill/show the entire data and chops off a significant portion of the gridview.
I should also note the Freeze Pane still operates as normal. However, with the parts of the GridView that are cut off in edit mode this defeats the purpose of 1) the GridView and 2) the Freeze Pane. I spent the better part of yesterday trying to figure out how I could apply the editing from initial page load to GridView editing mode. I shouldn't have to do this but it's something that needs to be done. I've been looking over the OnRowEditing Method as a possible answer as well as looking over the ASP options for GridView and Panel. I've even looked over the CSS to see if there's a solution but I'm stumped.
What I'm hoping to accomplish is to have the formatting that I like when the page loads stay uniform when the GridView goes into edit mode.
Here's a sample of what I'm seeing (note how the GridView in the pane slides):
Yes, this is a sandbox database but what I'm seeing on my actual code is more information being cut off than this on the end.
I'm trying to learn this so some pointers on the theory behind this would be great as well. Am I even on the right path by OnRowEditing method?
Here's the code:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="sample.aspx.cs" Inherits="sample" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="<path to>/jquery-2.0.3.min.js"></script>
<script src="<path to>/jquery-2.0.3.js"></script>
<style type="text/css">
.header-frozen
{
font-weight: bold;
background-color: white;
position: relative;
visibility: visible;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<div>
<asp:Panel ID="Panel1" Height="600px" Width="4000px" ScrollBars="Vertical" runat="server">
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="BusinessEntityID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
<HeaderStyle CssClass="GridViewHeaderStyle" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="BusinessEntityID" HeaderText="Business Entity ID" ReadOnly="True" SortExpression="BusinessEntityID" InsertVisible="False" ShowHeader="False" >
</asp:BoundField>
<asp:BoundField DataField="NationalIDNumber" HeaderText="National ID #" SortExpression="NationalIDNumber" ShowHeader="False" />
<asp:BoundField DataField="LoginID" HeaderText="Login ID" SortExpression="LoginID" ShowHeader="False" />
<asp:BoundField DataField="OrganizationNode" HeaderText="Organization Node" SortExpression="OrganizationNode" ShowHeader="False" />
<asp:BoundField DataField="OrganizationLevel" HeaderText="Organization Level" SortExpression="OrganizationLevel" ShowHeader="False" />
<asp:BoundField DataField="JobTitle" HeaderText="Job Title" SortExpression="JobTitle" ShowHeader="False" />
<asp:BoundField DataField="MaritalStatus" HeaderText="Marital Status" SortExpression="MaritalStatus" ShowHeader="False" />
<asp:BoundField DataField="HireDate" HeaderText="Hire Date" SortExpression="HireDate" ShowHeader="False" />
<asp:BoundField DataField="SalariedFlag" HeaderText="Salaried Flag" SortExpression="SalariedFlag" ShowHeader="False" />
<asp:BoundField DataField="VacationHours" HeaderText="Vacation Hours" SortExpression="VacationHours" InsertVisible="False" ReadOnly="True" ShowHeader="False" />
<asp:BoundField DataField="CurrentFlag" HeaderText="Current Flag" SortExpression="CurrentFlag" ShowHeader="False" />
<asp:BoundField DataField="rowguid" HeaderText="Row Guid" SortExpression="rowguid" ShowHeader="False" />
<asp:BoundField DataField="ModifiedDate" HeaderText="Modified Date" SortExpression="ModifiedDate" ShowHeader="False" />
<asp:CommandField ShowEditButton="True" />
</Columns>
<HeaderStyle CssClass="header-frozen" Height="60px" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle 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:AdventureWorks2012ConnectionString %>" SelectCommand="SELECT [BusinessEntityID],[NationalIDNumber],[LoginID],[OrganizationNode],[OrganizationLevel],[JobTitle],[BirthDate],[MaritalStatus],[Gender],[HireDate],[SalariedFlag],[VacationHours],[SickLeaveHours],[CurrentFlag],[rowguid],[ModifiedDate] FROM [HumanResources].[Employee]" UpdateCommand="UPDATE [HumanResources].[Employee] SET SELECT [NationalIDNumber] = #NationalIDNumber,[LoginID] = #LoginID,[OrganizationNode] = #OrganizationNode,[OrganizationLevel] = #OrganizationLevel,[JobTitle] = #JobTitle,[BirthDate] = #BirthDate,[MaritalStatus] = #MaritalStatus,[Gender] = #Gender,[HireDate] = #HireDate,[SalariedFlag] = #SalariedFlag,[VacationHours] = #VacationHours,[SickLeaveHours] = #SickLeaveHours,[CurrentFlag] = #CurrentFlag,[rowguid] = #rowguid,[ModifiedDate] = #ModifiedDate WHERE [BusinessEntityID] = #BusinessEntityID">
<UpdateParameters>
<asp:Parameter Name="NationalIDNumber" />
<asp:Parameter Name="LoginID" />
<asp:Parameter Name="OrganizationNode" />
<asp:Parameter Name="OrganizationLevel" />
<asp:Parameter Name="JobTitle" />
<asp:Parameter Name="BirthDate" />
<asp:Parameter Name="MaritalStatus" />
<asp:Parameter Name="Gender" />
<asp:Parameter Name="HireDate" />
<asp:Parameter Name="SalariedFlag" />
<asp:Parameter Name="VacationHours" />
<asp:Parameter Name="SickLeaveHours" />
<asp:Parameter Name="CurrentFlag" />
<asp:Parameter Name="rowguid" />
<asp:Parameter Name="ModifiedDate" />
<asp:Parameter Name="BusinessEntityID" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Panel>
</div>
</div>
</div>
</form>
</body>
</html>
I solved this by increasing the width of the panel to 9000 and everything seem to fit/work after that in edit mode.

Webpages jump up to the top when auto post back

I am having a problem when I mark some checkbox checked in a grid view, the page itself will jump back to the top instead of staying at the same position when auto post back. Here is how I set up my grid view:
<UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<!-- COLLAPSIBLE PANEL EXTENDER -->
<asp:Panel ID="pHeader1" runat="server" CssClass="cpHeader">
<!-- Collapsible panel extender header -->
<div class="form-group" style="background-color: #ffb848; height: 30px; vertical-align: middle">
<div class="col-md-3">
<div style="float: left; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblCategory" Text='<%# DataBinder.Eval(Container.DataItem, "categoryName") %>' runat="server" />
</div>
</div>
<div class="col-md-9">
<div style="float: right; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblHeaderText1" runat="server" />
</div>
</div>
<div style="clear: both"></div>
</div>
</asp:Panel>
<!-- Collapsible panel extender body -->
<asp:Panel ID="pBody1" runat="server" CssClass="cpBody">
<asp:Label ID="lblBodyText1" runat="server" />
<!-- Grid view to show products based on each category -->
<asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" Width="998px" CellPadding="4" ForeColor="#333333" GridLines="None" ShowHeader="False" DataKeyNames="id">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="cbCheckRow" runat="server" AutoPostBack="true"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Name" ItemStyle-Width="650px" />
<asp:BoundField DataField="inventoryQuantity" HeaderText="Total Unit" />
<asp:TemplateField HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200px">
<ItemTemplate>
<asp:TextBox ID="tbQuantity" runat="server" Width="40" Text="0" OnTextChanged="tbQuantity_TextChanged" AutoPostBack="true"/>
<asp:Label ID="lblCheckAmount" runat="server" ForeColor="#a94442"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#ffb848" ForeColor="White" />
<PagerStyle BackColor="#d8d8d8" ForeColor="#333333" HorizontalAlign="Left" />
<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>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpe1" runat="server" TargetControlID="pBody1" CollapseControlID="pHeader1"
ExpandControlID="pHeader1" Collapsed="true" TextLabelID="lblHeaderText1" CollapsedText="Show"
ExpandedText="Hide" CollapsedSize="0"
ScrollContents="false">
</asp:CollapsiblePanelExtender>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</UpdatePanel>
I've added the update panel. So far from my research, I know that we should use update panel to prevent the page jump up when auto post back. However, mine does not work. Any guides?
Thanks in advance.
You can use the MaintainScrollPositionOnPostback attribute of page Directive. See Sample below:
<%# Page MaintainScrollPositionOnPostback="true" %>

Insert using a submit button in ASP.NET doesn't work?

Hello I have a bit of ASP.Net Code below. I am trying to figure out how to make my submit button:
<asp:Button ID="makepost" runat="server" Text="Post My Tip/Story"
ValidationGroup="createpost" />
work properly. When I try to add AccessDataSource1.Insert() I get an error saying this:
CS1061: 'ASP.main_aspx' does not contain a definition for
'AccessDataSource1' and no extension method 'AccessDataSource1'
accepting a first argument of type 'ASP.main_aspx' could be found (are
you missing a using directive or an assembly reference?)
What do I need to type to make this work? All of my code is below.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Main.aspx.cs" Inherits="Main" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF">
<p style="font-size: 20px">Welcome Back!<br />
Begin Sharing and Reading Space Tips Below!
</p>
<p> Current Posts:
<asp:GridView ID="GridView1" runat="server" DataSourceID="AccessDataSource1"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="ID">
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:BoundField DataField="User" HeaderText="User" SortExpression="User" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Timeof" HeaderText="Timeof"
SortExpression="Timeof" />
<asp:BoundField DataField="Post" HeaderText="Post" SortExpression="Post" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/Posts.mdb"
SelectCommand="SELECT * FROM [UserPost] ORDER BY [Timeof]"
DeleteCommand="DELETE FROM [UserPost] WHERE [ID] = ?"
InsertCommand="INSERT INTO [UserPost] ([ID], [User], [Title], [Timeof], [Post]) VALUES (?, ?, ?, ?, ?)"
UpdateCommand="UPDATE [UserPost] SET [User] = ?, [Title] = ?, [Timeof] = ?, [Post] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="User" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Timeof" Type="DateTime" />
<asp:Parameter Name="Post" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter Name="ID" Type="Int32" ControlID="TextBox5" PropertyName="Text" />
<asp:ControlParameter Name="User" Type="String" ControlID="TextBox1" PropertyName="Text" />
<asp:ControlParameter Name="Title" Type="String" ControlID="TextBox2" PropertyName="Text" />
<asp:ControlParameter Name="Timeof" Type="DateTime" ControlID="TextBox3" PropertyName="Text" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="Post" Type="String" ControlID="TextBox4" PropertyName="Text" />
</InsertParameters>
</asp:AccessDataSource>
</p>
<table><tr><td> <asp:Label ID="Label5" runat="server" Text="ID: "></asp:Label></td><td>
<asp:TextBox ID="TextBox5" runat="server" ValidationGroup="createpost"></asp:TextBox></td></tr>
<tr><td> <asp:Label ID="Label1" runat="server" Text="User: "></asp:Label></td><td>
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="createpost"></asp:TextBox></td></tr>
<tr><td><asp:Label ID="Label2" runat="server" Text="Title: "></asp:Label></td><td><asp:TextBox ID="TextBox2"
runat="server" ValidationGroup="createpost"></asp:TextBox></td></tr>
<tr><td><asp:Label ID="Label3" runat="server" Text="Date: "></asp:Label></td><td> <asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox></td></tr>
<tr><td valign="top"><asp:Label ID="Label4" runat="server" Text="Story: "></asp:Label></td><td valign="top">
<asp:TextBox ID="TextBox4" runat="server" Height="129px" Width="474px" TextMode="MultiLine"></asp:TextBox></td></tr>
</table>
<asp:Button ID="makepost" runat="server" Text="Post My Tip/Story"
ValidationGroup="createpost" /><br />
</div>
</LoggedInTemplate><AnonymousTemplate>
<asp:Login ID="Login1" runat="server" ForeColor="White">
</asp:Login><br /><div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color:#FFFFFF">Please Register to be begin viewing and sharing your
<br />Star Wars Old Republic Tips and Stories!</div>
</AnonymousTemplate>
</asp:LoginView>
</asp:Content>
Your AccessDataSource is inside LoginView, you have to find the control:
Dim AccessDataSource1 As AccessDataSource = DirectCast(LoginView1.FindControl("AccessDataSource1"), AccessDataSource)
Regards.
in C# it would be this then
AccessDataSource AccessDataSource1 = (AccessDataSource)LoginView1.FindControl("AccessDataSource1");
'ASP.main_aspx' does not contain a definition for 'AccessDataSource1'
I think that your AccessDataSource control is located in the wrong place: you've put it in the LoginView. The error message says that the runtime can't find the control in the root of your page. So, try to put the AccessDataSource outside the LoginView.
This line. Take a look at:
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
Do you see AccessDataSource1? Are you perhaps pointing to the incorrect Datasource? Or, did you name it differently and not realize it?

ASP.NET Delete/Insert/Update issue but display works? Used wizard

I utilized the wizard to create Insert Edit Update and Delete statements. Problem is they are not work in my grid view. When I go to use them I get an error:
No value given for one or more required parameters.
I was wondering what could be the problem? It queries and displays data ok.
<LoggedInTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF">
<p style="font-size: 20px">Welcome Back!<br />
Begin Sharing and Reading Space Tips Below!
</p>
<p> Current Posts:
<asp:GridView ID="GridView1" runat="server" DataSourceID="AccessDataSource1"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="Title">
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title"
ReadOnly="True" />
<asp:BoundField DataField="User" HeaderText="User" SortExpression="User" />
<asp:BoundField DataField="Timeof" HeaderText="Date"
SortExpression="Timeof" />
<asp:BoundField DataField="Post" HeaderText="Post" SortExpression="Post" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/Posts.mdb"
SelectCommand="SELECT * FROM [UserPost] ORDER BY [Timeof]"
DeleteCommand="DELETE FROM [UserPost] WHERE (([Title] = ?) OR ([Title] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [UserPost] ([Title], [User], [Timeof], [Post]) VALUES (?, ?, ?, ?)"
UpdateCommand="UPDATE [UserPost] SET [User] = ?, [Timeof] = ?, [Post] = ? WHERE (([Title] = ?) OR ([Title] IS NULL AND ? IS NULL))">
<DeleteParameters>
<asp:Parameter Name="Title" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="User" Type="String" />
<asp:Parameter Name="Timeof" Type="DateTime" />
<asp:Parameter Name="Post" Type="String" />
<asp:Parameter Name="Title" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="User" Type="String" />
<asp:Parameter Name="Timeof" Type="DateTime" />
<asp:Parameter Name="Post" Type="String" />
</InsertParameters>
</asp:AccessDataSource>
</p>
<table>
<tr><td> <asp:Label ID="Label1" runat="server" Text="User: "></asp:Label></td><td>
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="createpost"></asp:TextBox></td></tr>
<tr><td><asp:Label ID="Label2" runat="server" Text="Title: "></asp:Label></td><td><asp:TextBox ID="TextBox2"
runat="server" ValidationGroup="createpost"></asp:TextBox></td></tr>
<tr><td><asp:Label ID="Label3" runat="server" Text="Date: "></asp:Label></td><td> <asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox></td></tr>
<tr><td valign="top"><asp:Label ID="Label4" runat="server" Text="Story: "></asp:Label></td><td valign="top">
<asp:TextBox ID="TextBox4" runat="server" Height="129px" Width="474px"
TextMode="MultiLine"></asp:TextBox></td></tr>
</table>
<asp:Button ID="makepost" runat="server" Text="Post My Tip/Story"
ValidationGroup="createpost" onclick="makepost_Click" /><br />
</div>
</LoggedInTemplate><AnonymousTemplate>
<asp:Login ID="Login1" runat="server" ForeColor="White">
</asp:Login><br /><div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color:#FFFFFF">Please Register to be begin viewing and sharing your
<br />Star Wars Old Republic Tips and Stories!</div>
</AnonymousTemplate>
</asp:LoginView>
I'm not very good with access now, but as I can see (and tested) in DeleteCommand you specify 2 parameters but just declare 1, this is not like SQL Server where you name the parameters and you can use one parameter a lot of time in the query, tha same occures in UpdateCommand but with more parameters... see in Where statement.
Try to do something like this:
DeleteCommand="DELETE FROM UserPost WHERE (Title = ?)"
UpdateCommand="UPDATE UserPost SET [User] = ?, Timeof = ?, Post = ? WHERE (Title = ?)"
I tested and it worked.
Edit: You most have an ID (unique primary key) in your table to work with it and not with the Title field.

Categories

Resources