Skip to main content
Participating Frequently
May 9, 2007
Question

Datagrid bound to filtered recordset

  • May 9, 2007
  • 1 reply
  • 231 views
I have a calendar that plugs into an Access database. I am implementing a search feature that will allow users to display records in a datagrid.

I have filtered the recordset based on the form variable. It works fine, except, when I try to page through the datagrid it throws an error, or if I try to edit a record, I just get a blank record.

I can post the code if necessary, but I am assuming that I need to somehow save the variable...

Thanks in advance
This topic has been closed for replies.

1 reply

Participating Frequently
May 9, 2007
<%@ Page Language="VB" validateRequest="false" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="dsCalendar"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_connCalendar") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connCalendar") %>'
CommandText='<%# "SELECT * FROM Events WHERE EventDate = ? ORDER BY EventDate ASC" %>'
PageSize="10"
FailureURL='<%# "oops.aspx" %>'
>
<Parameters>
<Parameter Name="@EventDate" Value='<%# IIf((Request.Form("EventDate") <> Nothing), Request.Form("EventDate"), "") %>' Type="Date" />
</Parameters>
<EditOps>
<EditOpsTable Name="Events" />
<Parameter Name="EventTitle" Type="LongVarWChar" IsPrimary="" />
<Parameter Name="EventDescription" Type="LongVarWChar" IsPrimary="" />
<Parameter Name="EventLocation" Type="LongVarWChar" IsPrimary="" />
<Parameter Name="EventTime" Type="VarWChar" IsPrimary="" />
<Parameter Name="EventDate" Type="Date" IsPrimary="" />
<Parameter Name="EventCategory" Type="Integer" IsPrimary="" />
<Parameter Name="EventID" Type="Integer" IsPrimary="true" />
</EditOps>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<customErrors mode="Off"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Update Events</title>
<style type="text/css">
<!--
body {
background-color: #2A6180;
}
div#Masthead {
background-color: #2A6180;
border: none #990000;
}
div#Body {
background-color: #FFFFFF;
}
h2 {
color: #FFFFFF;
background-color: #000000;
border: 1px solid #990000;
}
-->
</style></head>
<body>
<div id="Masthead">
<p align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="768" height="175">
<param name="movie" value="../Flash/Short.swf">
<param name="quality" value="high"><param name="LOOP" value="false">
<embed src="../Flash/Short.swf" width="768" height="175" loop="false" quality="high" pluginspage=" http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object>
</p>
</div>
<div id="Body">
<div align="center">
<p align="center"> </p>
<p align="center">Update Calendar Event
<form name="form1" method="post" action="SearchUpdateCalender.aspx">
<p align="center">Date
<label>
<input name="EventDate" type="text" id="EventDate">
</label>
</p>
<p align="center">
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</p>
</form>
<form runat="server">
<asp:DataGrid id="dgrdCalendar"
runat="server"
AllowSorting="False"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ShowFooter="false"
ShowHeader="true"
DataSource="<%# dsCalendar.DefaultView %>"
PagerStyle-Mode="NextPrev"
AllowPaging="true"
AllowCustomPaging="true"
PageSize="<%# dsCalendar.PageSize %>"
VirtualItemCount="<%# dsCalendar.RecordCount %>"
OnPageIndexChanged="dsCalendar.OnDataGridPageIndexChanged"
DataKeyField="EventID"
onCancelCommand="dsCalendar.OnDataGridCancel"
onEditCommand="dsCalendar.OnDataGridEdit"
onUpdateCommand="dsCalendar.OnDataGridUpdate"
onItemDataBound="dsCalendar.OnDataGridItemDataBound"
onDeleteCommand="dsCalendar.OnDataGridDelete"
>
<HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<Columns>
<asp:BoundColumn DataField="EventTitle"
HeaderText="EventTitle"
ReadOnly="false"
Visible="True"/>
<asp:BoundColumn DataField="EventDescription"
HeaderText="EventDescription"
ReadOnly="false"
Visible="True"/>
<asp:BoundColumn DataField="EventLocation"
HeaderText="EventLocation"
ReadOnly="false"
Visible="True"/>
<asp:BoundColumn DataField="EventTime"
HeaderText="EventTime"
ReadOnly="false"
Visible="True"/>
<asp:BoundColumn DataField="EventDate"
HeaderText="EventDate"
ReadOnly="false"
Visible="True"/>
<asp:BoundColumn DataField="EventCategory"
HeaderText="EventCategory"
ReadOnly="false"
Visible="True"/>
<asp:EditCommandColumn
ButtonType="LinkButton"
CancelText="Cancel"
EditText="Edit"
HeaderText="Edit"
UpdateText="Update"
Visible="True"/>
<asp:ButtonColumn
ButtonType="LinkButton"
CommandName="Delete"
HeaderText="Delete"
Text="Delete"
Visible="True"/>
</Columns>
</asp:DataGrid>
</form>
</p>
<p><a href="index.aspx">Back To Administration</a></p>
<p><a href="../MainCalendar.aspx">View Calendar</a></p>
<p> </p>
</div>
</div>

</body>
</html>