 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 16th, 2007, 05:12 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DataGrid/Hyperlink w multiple parameters
Hello,
I have been tring to get this datagrid with a hyperlink in the column to work with 2 parameters, but I keep getting a parser error.
System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'TemplateColumn' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'
Here is my code below, any ideas of what is causing this?
<asp:DataGrid ID="ProcDataGrid" AutoGenerateColumns="false" runat="server" OnItemDataBound="ProcDataGrid_ItemDataBound" Width="191px">
<Columns>
<TemplateColumn>
<ItemTemplate>
<asp:HyperLink Runat="server" NavigateUrl='<%#_
"ProcessDetail.aspx?ProcName=" & Container.DataItem("ProcName") & _
"&isInDictionary=" & Container.DataItem("isInDictionary") %>' >
</ItemTemplate>
</TemplateColumn>
</Columns>
|
|

February 19th, 2007, 10:17 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
You need to show your code behind for us to help with this error
|
|

February 20th, 2007, 01:04 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is my code behind. Hope this will shed some light. The values I want to use as parameters are ProcName and IsInDictionary. I have a DataGrid which binds to a list of processes, some of which are in the process dictionary and some are not. I want to send to my details page both the name of the process and weather or not it is currently in the dictionary. Thanks a lot for your help.
dictitems = getDictionaryProcs();
ArrayList someprocs = new ArrayList();
// 2. Using an IP address to specify the machineName parameter.
//Process[] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");
DataTable dt = new DataTable();
// Get all processes running on the local computer.
Process[] localAll = Process.GetProcesses();
for (int i = 0; i < localAll.GetLength(0); i++)
{
myProcesses mp = new myProcesses(localAll[i]);
someprocs.Add(mp);
}
ProcDataGrid.DataSource = someprocs;
ProcDataGrid.DataBind();
ProcDataGrid.Visible = true;
public class myProcesses
{
private Process myproc;
private string procname;
private bool inDictionary;
public myProcesses(Process proc)
{
this.myproc = proc;
this.procname = proc.ProcessName;
}
public Process MyProc { get { return myproc; } }
public string ProcName { get { return procname; } }
public bool isInDictionary
{
get
{
return inDictionary;
}
set
{
inDictionary = value;
}
}
}
|
|

February 20th, 2007, 04:08 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Try this:
Code:
<asp:DataGrid ID="ProcDataGrid" AutoGenerateColumns="false" runat="server" OnItemDataBound="ProcDataGrid_ItemDataBound" Width="191px" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Runat="server" NavigateUrl='<%#_
"ProcessDetail.aspx?ProcName=" & Container.DataItem("ProcName") & _
"&isInDictionary=" & Container.DataItem("isInDictionary") %>' ID="Hyperlink2" NAME="Hyperlink1">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
The bolded items are what you were missing.
|
|

February 20th, 2007, 04:39 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your help, but for some reason im still getting some syntax errors dealing with my code at the top of the aspx page
when I added your code. It seems to have something to do with these <% type tags. Sorry Im pretty new to asp.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ProcessDictionary.aspx.cs" Inherits="_Default" %>
|
|

February 20th, 2007, 04:51 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
If you are creating pages without the help of VS, then you will probably run into many syntax problems. Do you have visual studio available to use to create your pages?
|
|

February 20th, 2007, 05:38 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
oh yeah Im using VS 2005
|
|

February 20th, 2007, 06:24 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
What is the error and at what line?
|
|

February 20th, 2007, 07:31 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error 1 Cannot switch views: Validation (ASP.Net): Attribute 'runat' can be specified only once in a tag. W:\ProcessDictionary.aspx 24 139 Miscellaneous Files
Error 3 ) expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 4 ; expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 5 ; expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 6 ; expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 7 Invalid expression term ',' W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 8 ; expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 9 ; expected W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
Error 10 Invalid expression term ')' W:\ProcessDictionary.aspx 1 1 Miscellaneous Files
MOst of these are coming from line 1, which is
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ProcessDictionary.aspx.cs" Inherits="_Default" %>
|
|

February 21st, 2007, 10:21 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Quote:
|
quote:Attribute 'runat' can be specified only once in a tag.
|
that is your problem...
|
|
 |