cancel
Showing results for 
Search instead for 
Did you mean: 

Another Modification question :)

c_oudeluttikhuis
Explorer
0 Kudos

ok, my last post was about getting DisplayName from user table and get it into the datagrid.

now im trying something similar, im trying to get an extra column with the postalcode in the customers.ascx from the dashboard.

i have learned a lot from my last post and i know now what kind of methods and data is available in netpoint.dll

Since customers from the api isnt that complex compared to the accountsearch if tried the following code

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="customers.ascx.cs" Inherits="netpoint.dashboard.controls.customers" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

<%@ Page Language="C#" Inherits="netpoint.classes.NPBasePage" %>

<%@ Import Namespace = "netpoint.api.utility" %>

<%@ Import Namespace = "netpoint.api.account" %>

<%@ Import Namespace = "System.Data" %>

<script runat="server">

protected void Grid_ItemDataBound(object sender, DataGridItemEventArgs e)

{

NPBasePage page = (NPBasePage)this.Page;

DataRowView MyRow = (DataRowView)e.Item.DataItem;

if (myRow == null) return;

String PostalCode = address.PostalCode;

Literal literal4 = (Literal)e.Item.FindControl("ltlPostalCode");

}

</script>

<asp:datagrid id="grid" PageSize="50" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"

Width="100%" runat="server">

<ItemStyle CssClass="npadminbody"></ItemStyle>

<AlternatingItemStyle CssClass="npadminbodyalt"></AlternatingItemStyle>

<HeaderStyle CssClass="npadminsubheader"></HeaderStyle>

<Columns>

<asp:HyperLinkColumn DataTextField="AccountName" HeaderText="colName" SortExpression="AccountName" DataNavigateUrlField="AccountID"

DataNavigateUrlFormatString="~/admin/common/accounts/AccountInfo.aspx?accountid="></asp:HyperLinkColumn>

<asp:TemplateColumn HeaderText="PostalCode" SortExpression="PostalCode">

<ItemTemplate>

<asp:Literal ID="ltlPostalCode" runat="server"></asp:Literal>

</ItemTemplate>

</asp:TemplateColumn>

the rest of the code is not interresting since its not changing.

the problem is when i try to run this it gives the following error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The directive 'Page' is unknown.

Source Error:

Line 1: <%@ Control Language="c#" AutoEventWireup="false" Codebehind="customers.ascx.cs" Inherits="netpoint.dashboard.controls.customers" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

***Line 2: <%@ Page Language="C#" Inherits="netpoint.classes.NPBasePage" %>**** error here

Line 3: <%@ Import Namespace = "netpoint.api.utility" %>

Line 4: <%@ Import Namespace = "netpoint.api.account" %>

so i was wondering if some of you guys give a look at it and could tell me what im doing wrong (or its not even possible )

thnx

Kind regards,

C. Oude Luttikhuis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi C Oude,

glad to see you are getting stuck in

the problm is that this is a control tyou are modifying; whereas the line in error is trying to give a @Page directive; this is only valid on a Page (like a .aspx webform). So take the line out. Also the Control already inherits from the netpoint.dashboard.controls.customer control so you don't need to (in fact you can't) inherit from anything else.

However even when you fix this error, I don;t think the control will work as you expected. Specifically, because there is no code that actually tells the Grid to bind to a datasource...the Grid_ItemDatabound only gets called after you have bound data to the grid using Bind()

So for example you would need to write a Page_Load handler that would take data that had just been posted to the control's containing page, then get your list of customers (probably an arraylist or dataset) using this data, and then bind it to the grid.

Don't be discouraged though, I am on vacation at the moment but when I get back in a few days I will have a look at it for you and try and come up with a solution.

Answers (0)