I have tried the last few days to create a grid filter using the following Demo, however I am failing.
I am receiving the following error:
"JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value"
To eliminate this error I remove the following piece of code: "SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("colEquipmentType").CurrentFilterValue %>'"
When I remove this code the filter works fine, however the combo box does not repopulate correctly. The only item in the combo box is "All".
Is this issue because I am using a data layer to populate the combo box filter?
.aspx
.cs
Update:
I setup the "colDateIssue" column for filtering, again using the demo, that filter is working perfectly fine. HMMMM?
I am receiving the following error:
"JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value"
To eliminate this error I remove the following piece of code: "SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("colEquipmentType").CurrentFilterValue %>'"
When I remove this code the filter works fine, however the combo box does not repopulate correctly. The only item in the combo box is "All".
Is this issue because I am using a data layer to populate the combo box filter?
.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EquipmentManager2.aspx.cs" Inherits="EquipmentManager2" EnableEventValidation="false" %><!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>Equipment Manager</title> <link href="../StyleSheets/Window.HansonsError.css" rel="stylesheet" type="text/css" /> <style type="text/css"> html, body, form { height: 100% !important; margin: 0px; padding: 0px; overflow: hidden; } body { background-image: url("../Images/Background.png"); background-repeat: repeat; } .PageTitle { border-style: none; height: 50px; width: 100%; font-size: xx-large; font-weight: bold; text-align: center; color: Navy; font-family: MS Sans Serif; } .label { font-family: Arial; width: 135px; font-size: small; text-align: left; padding-left: 10px; } .control { font-family: Arial; width: 5px; font-size: small; } .grid { padding-left: 15px; } </style></head><body> <table class="PageTitle" cellpadding="0" cellspacing="0"> <tr> <td> Equipment Manager </td> </tr> </table> <hr /> <form id="form1" runat="server"> <telerik:RadWindow ID="rwErrors" runat="server" Behaviors="Close" EnableEmbeddedSkins="false" Skin="HansonsError"> <ContentTemplate> <asp:ListBox ID="lbErrors" runat="server"></asp:ListBox> </ContentTemplate> </telerik:RadWindow> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <%--Equipment Type--%> <td class="label"> Equipment Type: </td> <td class="control"> <telerik:RadComboBox ID="cboEquipmentType" runat="server" EmptyMessage="Select Equipment Type" AllowCustomText="True" /> </td> <%--Grid--%> <td class="grid" rowspan="9"> <telerik:RadScriptManager runat="server" ID="RadScriptManager1" /> <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="rgEquipmentRecords"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="rgEquipmentRecords" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadGrid runat="server" ID="rgEquipmentRecords" CellSpacing="0" Skin="Vista" Width="98%" AutoGenerateColumns="False" GridLines="None" AllowSorting="True" OnNeedDataSource="rgEquipmentRecords_NeedDataSource" AllowPaging="True" GroupingEnabled="False" AllowFilteringByColumn="True" PageSize="13" OnItemDataBound="rgEquipmentRecords_ItemDataBound" OnItemCommand="rgEquipmentRecords_ItemCommand"> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="true" /> </ClientSettings> <AlternatingItemStyle BackColor="AliceBlue" /> <ItemStyle BackColor="White" /> <PagerStyle AlwaysVisible="True" ShowPagerText="False" PageButtonCount="13" /> <MasterTableView DataKeyNames="EquipmentType,Qty,IssuedTo,DateIssued,Approvedby,IssuedBy,ID,Notes"> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <%--Grid Column Record Id--%> <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="true" UniqueName="colID" ItemStyle-HorizontalAlign="center" AllowFiltering="False"> <HeaderStyle HorizontalAlign="Center" Width="30px" /> <ItemStyle HorizontalAlign="Left"></ItemStyle> </telerik:GridBoundColumn> <%--Grid Column Equipment Type--%> <telerik:GridBoundColumn DataField="EquipmentType" HeaderText="Equip Type" ReadOnly="true" UniqueName="colEquipmentType" ItemStyle-HorizontalAlign="Left"> <HeaderStyle Width="100px" /> <ItemStyle HorizontalAlign="Left"></ItemStyle> <%--Equipment Type Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboEquipmentTypeFilter" DataTextField="DESC" DataValueField="DESC" Height="200px" Width="135px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("colEquipmentType").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="EquipmentTypeIndexChanged"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> function EquipmentTypeIndexChanged(sender, args) { var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); tableView.filter("colEquipmentType", args.get_item().get_value(), "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column QTY--%> <telerik:GridBoundColumn DataField="Qty" HeaderText="QTY" ReadOnly="true" UniqueName="colQty" ItemStyle-HorizontalAlign="Center" AllowFiltering="False"> <HeaderStyle HorizontalAlign="Center" Width="30px" /> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridBoundColumn> <%--Grid Column BarCode Number--%> <telerik:GridBoundColumn DataField="BarcodeNumber" HeaderText="Barcode" ReadOnly="true" UniqueName="colBarcode" ItemStyle-HorizontalAlign="Center" AllowFiltering="False"> <HeaderStyle HorizontalAlign="Center" Width="80px" /> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridBoundColumn> <%--Grid Column Department--%> <telerik:GridBoundColumn DataField="Department" HeaderText="Dept" ReadOnly="true" UniqueName="colDept" ItemStyle-HorizontalAlign="Left"> <HeaderStyle Width="90px" /> <ItemStyle HorizontalAlign="Left"></ItemStyle> <%--Department Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboDepartmentFilter" DataTextField="DESC" DataValueField="DESC" ColName="colDept" Height="200px" Width="115px" AppendDataBoundItems="true" runat="server"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Division--%> <telerik:GridBoundColumn DataField="Division" HeaderText="Div" ReadOnly="true" UniqueName="colDiv" ItemStyle-HorizontalAlign="Left"> <HeaderStyle Width="90px" /> <ItemStyle HorizontalAlign="Left"></ItemStyle> <%--Division Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboDivisionFilter" DataTextField="DESC" DataValueField="DESC" ColName="colDiv" Height="200px" Width="115px" AppendDataBoundItems="true" runat="server"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Issued To--%> <telerik:GridBoundColumn DataField="IssuedTo" HeaderText="Issued To" ReadOnly="true" UniqueName="colIssuedTo" ItemStyle-HorizontalAlign="Left"> <HeaderStyle Width="90px" /> <ItemStyle HorizontalAlign="Left"></ItemStyle> <%--Issued To Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboIssuedToFilter" DataTextField="empltxtFullNameLF" DataValueField="empltxtFullNameLF" ColName="colIssuedTo" Height="200px" Width="115px" AppendDataBoundItems="true" runat="server"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Date Issued--%> <telerik:GridBoundColumn DataField="DateIssued" HeaderText="Date Issue" ReadOnly="true" UniqueName="colDateIssue"> <HeaderStyle Width="90px" /> <%--Date Issued Filter--%> <FilterTemplate> <telerik:RadDatePicker ID="calDateIssued" Width="100px" AppendDataBoundItems="true" runat="server"> </telerik:RadDatePicker> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Approved By--%> <telerik:GridBoundColumn DataField="Approvedby" HeaderText="Approved By" ReadOnly="true" UniqueName="colApprovedby"> <HeaderStyle Width="90px" /> <%--Approved By Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboApprovedbyFilter" DataTextField="empltxtFullNameLF" DataValueField="empltxtFullNameLF" ColName="colApprovedby" Height="200px" Width="120px" AppendDataBoundItems="true" runat="server"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Issued By--%> <telerik:GridBoundColumn DataField="IssuedBy" HeaderText="Issued By" ReadOnly="true" UniqueName="colIssuedBy"> <HeaderStyle Width="90px" /> <%--Issued By Filter--%> <FilterTemplate> <telerik:RadComboBox ID="cboIssuedByFilter" DataTextField="empltxtFullNameLF" DataValueField="empltxtFullNameLF" ColName="colIssuedBy" Height="200px" Width="125px" AppendDataBoundItems="true" runat="server"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <%--Grid Column Notes--%> <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes" ReadOnly="true" UniqueName="colNotes" AllowFiltering="False"> <HeaderStyle Width="150px" /> </telerik:GridBoundColumn> <%--Grid Column Delete--%> <telerik:GridButtonColumn UniqueName="colDelete" HeaderText="Delete" ButtonType="ImageButton" ItemStyle-HorizontalAlign="center" ConfirmText="This action will delete the selected record, are you sure?" ConfirmDialogType="RadWindow" CommandName="Delete" ImageUrl="~/Images/Icons/DeleteRed.png"> <HeaderStyle Width="40px" /> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridButtonColumn> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> <PagerStyle PageButtonCount="13" /> <HeaderStyle Font-Bold="true" Font-Size="Small" Height="10px" /> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> </td> </tr> <tr> <%--QTY--%> <td class="label"> Qty Issue: </td> <td class="control"> <telerik:RadNumericTextBox ID="txtQuantityEmployeeIssued" runat="server" Height="20px" MaxValue="1000"> <NumberFormat DecimalDigits="0" AllowRounding="false" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td class="label"> Issue To Department: </td> <td class="control"> <telerik:RadComboBox ID="cboDept" runat="server" EmptyMessage="Select Dept" AllowCustomText="True" /> </td> </tr> <tr> <td class="label"> Issue To Division: </td> <td class="control"> <telerik:RadComboBox ID="cboDiv" runat="server" EmptyMessage="Select Divison" AllowCustomText="True" /> </td> </tr> <tr> <td class="label"> Issue To Employee: </td> <td class="control"> <telerik:RadComboBox ID="cboIssueEmployee" runat="server" EmptyMessage="Select Issuing Employee" AllowCustomText="True" /> </td> </tr> <tr> <td class="label"> Approved By: </td> <td class="control"> <telerik:RadComboBox ID="cboApprovedBy" runat="server" EmptyMessage="Select Approving Employee" AllowCustomText="True" /> </td> </tr> <tr> <td class="label"> Barcode: </td> <td class="control"> <telerik:RadNumericTextBox ID="txtBarcode" runat="server"> <NumberFormat DecimalDigits="0" AllowRounding="false" GroupSeparator="" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td class="label"> Comments: </td> <td class="control"> <telerik:RadTextBox ID="txtComments" runat="server" Skin="Office2010Blue" AutoPostBack="true" TextMode="MultiLine" Height="50px" Width="180px" Style="margin-bottom: 0px"> </telerik:RadTextBox> </td> </tr> <tr> <td class="label"> </td> <td class="control"> <asp:Button ID="btnSubmit" CssClass="SubmitButton" runat="server" CommandName="Submit" Text="Submit" BackColor="White" BorderWidth="1px" OnClick="btnSubmit_Click" BorderColor="Black" BorderStyle="Solid" Font-Size="Medium" ForeColor="Black" Height="33px" Width="98px" /> </td> </tr> </table> <hr /> <%--Error window--%> <telerik:RadScriptBlock ID="rsbEquipmentManager" runat="server"> <script type="text/javascript"> function DisplayError() { var wnd = $find("<%= rwErrors.ClientID %>"); wnd.show(); wnd.center(); }// function TitleIndexChanged(sender, args) {// var grid = $find("<%= rgEquipmentRecords.ClientID %>");// var tableView = grid.get_masterTableView();// tableView.filter(sender._element.getAttribute("ColName"), args.get_item().get_value(), "EqualTo");// } </script> </telerik:RadScriptBlock> </form></body></html>.cs
using System;using System.Linq;using System.Web.UI;using System.Web.UI.WebControls;using HIWS;using Telerik.Web.UI;using System.Data;public partial class EquipmentManager2 : HansonsWebPage{ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Bind all the comboboxes BindToDataTable(cboEquipmentType); BindToDataTable(cboIssueEmployee); BindToDataTable(cboApprovedBy); BindToDataTable(cboDept); BindToDataTable(cboDiv); } } protected void rgEquipmentRecords_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { //Bind data to grid using(DataSet ds = WSAccess.StepsGlobal_GetComputerEquipmentsIssued()) { if (Globals.IsValidDataSet(ds)) { rgEquipmentRecords.DataSource = ds; } } } //protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) //{ // RadComboBox continentsCombo = o as RadComboBox; // //save the combo selected value // ViewState["continentsComboValue"] = continentsCombo.SelectedValue; // //filter the grid // rgEquipmentRecords.MasterTableView.FilterExpression = "colEquipmentType = '%" + continentsCombo.SelectedValue + "%'"; // rgEquipmentRecords.Rebind(); //} //protected void cboEquipmentTypeFilter_PreRender(object sender, EventArgs e) //{ // //persist the combo selected value // if (ViewState["continentsComboValue"] != null) // { // RadComboBox continentsCombo = sender as RadComboBox; // continentsCombo.SelectedValue = ViewState["continentsComboValue"].ToString(); // } //} protected void rgEquipmentRecords_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (!IsPostBack) { if (e.Item is GridFilteringItem) { GridFilteringItem item = (GridFilteringItem)e.Item; // Bind Code Table(Equipment Type Filter) RadComboBox cmb = (RadComboBox)item.FindControl("cboEquipmentTypeFilter"); using (DataSet dsEquipmentType3 = WSAccess.StepsGlobal_GetCodeTable("codComputerEquipmentTypes")) { if (Globals.IsValidDataSet(dsEquipmentType3)) { foreach (DataRow row in dsEquipmentType3.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["DESC"].ToString()); cmb.Items.Add(rcbi); } } } // Bind To Data Set(Approved by Filter) RadComboBox cmb1 = (RadComboBox)item.FindControl("cboApprovedbyFilter"); using (DataSet dsApprovedBy = WSAccess.StepsGlobal_GetEmployeesBySecurityItem(400, 1, System.DateTime.Now, 0, 0)) { if (Globals.IsValidDataSet(dsApprovedBy)) { foreach (DataRow row in dsApprovedBy.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["empltxtFullNameLF"].ToString(), row["empltxtFullNameLF"].ToString()); cmb1.Items.Add(rcbi); } } } // Bind To Data Set(Approved by Filter) RadComboBox cmb3 = (RadComboBox)item.FindControl("cboIssuedByFilter"); using (DataSet dsIssuedBy = WSAccess.StepsGlobal_GetEmployeesBySecurityItem(400, 1, System.DateTime.Now, 0, 0)) { if (Globals.IsValidDataSet(dsIssuedBy)) { foreach (DataRow row in dsIssuedBy.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["empltxtFullNameLF"].ToString(), row["empltxtFullNameLF"].ToString()); cmb3.Items.Add(rcbi); } } } // Bind To Data Set(Division Filter) RadComboBox cmb4 = (RadComboBox)item.FindControl("cboDivisionFilter"); using (DataSet dsDiv = WSAccess.StepsGlobal_GetCodeTable("codDivisions")) { if (Globals.IsValidDataSet(dsDiv)) { foreach (DataRow row in dsDiv.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["DESC"].ToString()); cmb4.Items.Add(rcbi); } } } // Bind To Data Set(Department Filter) RadComboBox cmb5 = (RadComboBox)item.FindControl("cboDepartmentFilter"); using (DataSet dsDept = WSAccess.StepsGlobal_GetCodeTable("codDepartments")) { if (Globals.IsValidDataSet(dsDept)) { foreach (DataRow row in dsDept.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["DESC"].ToString()); cmb5.Items.Add(rcbi); } } } RadComboBox cmb6 = (RadComboBox)item.FindControl("cboIssuedToFilter"); using (DataSet dsIssueEmployee = WSAccess.StepsGlobal_GetComputerEquipmentEmployeeRecipients()) { if (Globals.IsValidDataSet(dsIssueEmployee)) { foreach (DataRow row in dsIssueEmployee.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["empltxtFullNameLF"].ToString(), row["empltxtFullNameLF"].ToString()); cmb6.Items.Add(rcbi); } } } } } } private void BindToDataTable(RadComboBox combo) { switch (combo.ID) { case "cboEquipmentType": // Bind Code Table(Equipment Type) using (DataSet dsEquipmentType = WSAccess.StepsGlobal_GetCodeTable("codComputerEquipmentTypes")) { if (Globals.IsValidDataSet(dsEquipmentType)) { foreach (DataRow row in dsEquipmentType.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["ID"].ToString()); combo.Items.Add(rcbi); } } } break; case "cboIssueEmployee": // Bind To Data Set(Issue Employee) using (DataSet dsIssueEmployee = WSAccess.StepsGlobal_GetComputerEquipmentEmployeeRecipients()) { if (Globals.IsValidDataSet(dsIssueEmployee)) { foreach (DataRow row in dsIssueEmployee.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["empltxtFullNameLF"].ToString(), row["empllngID"].ToString()); combo.Items.Add(rcbi); } } } break; case "cboApprovedBy": // Bind To Data Set(Approved by) using (DataSet dsApprovedBy = WSAccess.StepsGlobal_GetEmployeesBySecurityItem(400, 1, System.DateTime.Now, 0, 0)) { if (Globals.IsValidDataSet(dsApprovedBy)) { foreach (DataRow row in dsApprovedBy.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["empltxtFullNameLF"].ToString(), row["empllngID"].ToString()); combo.Items.Add(rcbi); } } } break; case "cboDiv": // Bind Code Table(Division) using (DataSet dsDiv = WSAccess.StepsGlobal_GetCodeTable("codDivisions")) { if (Globals.IsValidDataSet(dsDiv)) { foreach (DataRow row in dsDiv.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["ID"].ToString()); combo.Items.Add(rcbi); } } } break; case "cboDept": // Bind Code table(Department) using (DataSet dsDept = WSAccess.StepsGlobal_GetCodeTable("codDepartments")) { if (Globals.IsValidDataSet(dsDept)) { foreach (DataRow row in dsDept.Tables[0].Rows) { RadComboBoxItem rcbi = new RadComboBoxItem(row["DESC"].ToString(), row["ID"].ToString()); combo.Items.Add(rcbi); } } } break; default: break; } } protected void btnSubmit_Click(object sender, EventArgs e) { //This is the employee that is logged in int intIssueEmp = Convert.ToInt32(HansonsEmployee.EmployeeID); //Create new Computer Equipment Issue object ComputerEquipmentIssue objCei = new ComputerEquipmentIssue(); //Fill in new Computer Equipment Issue object //******************************************************************************************************************** //QTY int intQty = 0; if (txtQuantityEmployeeIssued.Text != "") { intQty = Convert.ToInt32(txtQuantityEmployeeIssued.Text); } objCei.Quantity = intQty; //******************************************************************************************************************** //Issueing emp this is based off who is logged in {int intIssueEmp = Convert.ToInt32(HansonsEmployee.EmployeeID);} objCei.IssuedByEmployeeID = intIssueEmp; //******************************************************************************************************************** //Dept equipment is being issued int intDept = 0; if (cboDept.SelectedIndex != -1) { intDept = Convert.ToInt32(cboDept.SelectedValue); } objCei.IssuedToDepartmentID = intDept; //******************************************************************************************************************** //Div equipment is being issued int intDiv = 0; if (cboDiv.SelectedIndex != -1) { intDiv = Convert.ToInt32(cboDiv.SelectedValue); } objCei.IssuedToDivisionID = intDiv; //******************************************************************************************************************** //Equipment being issued int intEquip = 0; if (cboEquipmentType.SelectedIndex != -1) { intEquip = Convert.ToInt32(cboEquipmentType.SelectedValue); } objCei.ComputerEquipmentTypeID = intEquip; //******************************************************************************************************************** //Notes objCei.Notes = txtComments.Text; //******************************************************************************************************************** //Employee that equipment is being issued int intIssEmp = 0; if (cboIssueEmployee.SelectedIndex != -1) { intIssEmp = Convert.ToInt32(cboIssueEmployee.SelectedValue); } objCei.IssuedToEmployeeID = intIssEmp; //******************************************************************************************************************** //Date equipment is being issued - Todays date objCei.DateIssued = DateTime.Today; //******************************************************************************************************************** //Employee that approved the equipment to be issued int intAppEmp = 0; //Was an emp selected? if not use the default = 0 if (cboApprovedBy.SelectedIndex != -1) { intAppEmp = Convert.ToInt32(cboApprovedBy.SelectedValue); } objCei.ApprovedEmployeeID = intAppEmp; //******************************************************************************************************************** //Barcode int intBarcode = 0; if (txtBarcode.Text != "") { intBarcode = Convert.ToInt32(txtBarcode.Text); } objCei.BarcodeNumber = intBarcode; //******************************************************************************************************************** FunctionReturnObject retVal = new FunctionReturnObject(); //******************************************************************************************************************** //Insert record and receive back any errors retVal = WSAccess.StepsGlobal_AddEditComputerEquipmentIssue(objCei); //Find out if there is any error; if there is an error/s parse throught the error/s and display them to user if (retVal.Errors.Count() > 0) { lbErrors.Items.Clear(); foreach (ErrorContainer eo in retVal.Errors) { if (!eo.IsSystemError) { ListItem li = new ListItem(eo.Error, eo.Error); lbErrors.Items.Add(li); } } string script = "<script language='javascript'>function f(){DisplayError(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "DisplayError", script, false); } else { //******************************************************************************************************************** //Clear fields Refresh gird txtQuantityEmployeeIssued.Text = ""; cboDept.ClearSelection(); cboDiv.ClearSelection(); cboEquipmentType.ClearSelection(); txtComments.Text = ""; cboIssueEmployee.ClearSelection(); cboApprovedBy.ClearSelection(); txtBarcode.Text = ""; rgEquipmentRecords.Rebind(); } } protected void rgEquipmentRecords_ItemCommand(object sender, GridCommandEventArgs e) { //Did the delete button get click, if so flag record as deleted if (e.CommandName == "Delete") { if (e.Item is GridDataItem) { //Retrieve the index of the row GridDataItem gdiEquipmentRecords = (GridDataItem)e.Item; //Get the value of the control based off the row clicked (We need the value of the ID field; [record Id]) string intRecordId = gdiEquipmentRecords.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString(); ComputerEquipmentIssue objCei = WSAccess.StepsGlobal_GetComputerEquipmentIssue(intRecordId); //Set the property (bit flag) to the EquipmentRecords object to pass to the StepsGlobal_AddEditComputerEquipmentIssue function objCei.DeleteFlag = true; //******************************************************************************************************************** FunctionReturnObject retVal = new FunctionReturnObject(); //******************************************************************************************************************** //Retrieve record object for editing retVal = WSAccess.StepsGlobal_AddEditComputerEquipmentIssue(objCei); //Was there errors if so deal with them //System error are the only thing that needs to be handled if (retVal.Errors.Count() > 0) { // // foreach ( cboEmployee.ClearSelection(); cboEmployee.ClearSelection(); } else { } //Refresh the grid to show that record was deleted or was not deleted } rgEquipmentRecords.Rebind(); } }}Update:
I setup the "colDateIssue" column for filtering, again using the demo, that filter is working perfectly fine. HMMMM?
