Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old February 16th, 2007, 05:12 PM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>

  #2 (permalink)  
Old February 19th, 2007, 10:17 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You need to show your code behind for us to help with this error

  #3 (permalink)  
Old February 20th, 2007, 01:04 PM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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;
            }

        }


    }


  #4 (permalink)  
Old February 20th, 2007, 04:08 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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.

  #5 (permalink)  
Old February 20th, 2007, 04:39 PM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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" %>

  #6 (permalink)  
Old February 20th, 2007, 04:51 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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?

  #7 (permalink)  
Old February 20th, 2007, 05:38 PM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh yeah Im using VS 2005

  #8 (permalink)  
Old February 20th, 2007, 06:24 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What is the error and at what line?

  #9 (permalink)  
Old February 20th, 2007, 07:31 PM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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" %>


  #10 (permalink)  
Old February 21st, 2007, 10:21 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Quote:
quote:Attribute 'runat' can be specified only once in a tag.
that is your problem...





Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with multiple parameters and datagrid gobotsoup General .NET 0 February 16th, 2007 05:08 PM
hyperlink in a datagrid? bhavna General .NET 1 January 25th, 2007 12:37 PM
Multiple parameters for a datagrid jgsuter ASP.NET 2.0 Professional 1 June 14th, 2006 09:31 AM
Creating a hyperlink with multiple values rayncarnation ASP.NET 1.0 and 1.1 Basics 0 October 13th, 2005 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.