So I'm having a little trouble trying to figure out what exactly I'm doing wrong here. I'll give you a basic rundown of what I've been doing.
I am creating a Details with and one line of data is a boolean, We were using a CheckBoxField originally but now we are to remove that and use Boolean (True or False changed to Yes or No). So I removed the CheckBowField, set the DataField to 'Discontinued', I then use the code;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CustomFormatting_DetailsViewTemplateField : System.Web.UI.Page
{
protected string DisplayDiscontinuedAsYESorNO(bool discontinued)
{
if (discontinued)
return "YES";
else
return "NO";
}
}
Into my .aspx.cs page and I come up with this error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'ASP.customformatting_detailsviewtemplatefield_aspx' does not contain a definition for 'DetailsView1_PageIndexChanging' and no extension method 'DetailsView1_PageIndexChanging' accepting a first argument of type 'ASP.customformatting_detailsviewtemplatefield_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 3:
Line 4: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
Line 5: <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
Line 6: DataKeyNames="ProductID" DataSourceID="ObjectDataSource1"
Line 7: onpageindexchanging="DetailsView1_PageIndexChanging">
And lastly, here is the code for my DetailsView
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="ProductID" DataSourceID="ObjectDataSource1"
onpageindexchanging="DetailsView1_PageIndexChanging">
<Fields>
<asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />
<asp:BoundField DataField="SupplierName" HeaderText="Supplier" ReadOnly="True" SortExpression="SupplierName" />
<asp:BoundField DataField="QuantityPerUnit" HeaderText="Qty/Unit" SortExpression="QuantityPerUnit" />
<asp:TemplateField HeaderText="Price and Inventory">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("UnitPrice", "{0:C}") %>'></asp:Label>
<br />
<strong>(In Stock / On Order: </strong>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("UnitsInStock") %>'></asp:Label>
<strong>/</strong>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("UnitsOnOrder") %>'>
</asp:Label><strong>)</strong>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UnitPrice" HeaderText="Price" SortExpression="UnitPrice"
DataFormatString="{0:c}" Visible="False" />
<asp:BoundField DataField="UnitsIStock" HeaderText="Units In Stock" SortExpression="UnitsInStock"
Visible="False" />
<asp:BoundField DataField="UnitsOnOrder" HeaderText="Units On Order" SortExpression="UnitsOnOrder"
Visible="False" />
<asp:TemplateField HeaderText="Discontinued">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Discontinued") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Discontinued") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Discontinued") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
Sorry if I have posted way too much code, I'm just not too sure of what you may need to help my figure out my problem. I'm still new to this whole Visual Basic stuff. Many thanks in advice!