Solved

ItemTemplate (Menu)

Posted on 2007-03-19
9
513 Views
Last Modified: 2012-05-05
Hi All,

I am using C# along with a GridView. The gridview contains an ID field for each record on the grid.
I have an ItemTemplate field in my GridView that contains a Menu object.

Question:
1. When a user selects an item from the Menu object pertaining to ID #4 on the grid how can i capture the GridViews ID (#4) Field in the Menu_MenuItemClick event?

0
Comment
Question by:joan2006
  • 5
  • 2
9 Comments
 
LVL 14

Expert Comment

by:dfu23
ID: 18750957
either DataKeys or get the value from the cell itself:
MyGridView.SelectedItem.Cells[intIDCellIndex].InnerText
0
 

Author Comment

by:joan2006
ID: 18751143
i have tried the following

int k = Convert.ToInt32(GridView1.SelectedRow.Cells[4].Text);
int l = int.Parse(row.Cells[2].Text);  

Also, dfu23 .... there is no "SelectedItem"  for my GridView

None of these attempts return the value.
0
 

Author Comment

by:joan2006
ID: 18751312
Here is a code snip of the MenuItemClick event

protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
        {
         
            //int l = int.Parse(row.Cells[2].Text);  //Nee to Get ID from grid
            //Menu selitem = (Menu)GridView1.Rows[4].FindControl("Comments");
           
            switch (e.Item.Value)
            {
                case "Comments":
                    Response.Write("<script>window.open('Comments.aspx?xID=" + l + " ','_new', 'width=600,height=330, menubar = no, scrollbars = no resizable = no');</script>");
                    break;
                case "KeyView":
                    break;
                case "SupView":
                    break;
                case "Reload":
                    break;
            }
           
        }
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Expert Comment

by:dfu23
ID: 18751762
i'm sorry ... i missed the part about the Menu ... what kind of object is this?
0
 

Author Comment

by:joan2006
ID: 18756651
:) ... I am using the Menu CONTROL from the Toolbox listed under Navigation.

I just dropped the Menu control into the ItemTemplate and now i need to know how to access values from the Grid from the menu when an item in the menu is clicked.
0
 

Author Comment

by:joan2006
ID: 18794421
Can anyone help me with my problem?
0
 

Accepted Solution

by:
joan2006 earned 0 total points
ID: 18794585
Nevermind guys,

I found the answer:

Menu selecteditem = (Menu)sender;

GridViewRow row = (GridViewRow)selecteditem.NamingContainer;
 int l = System.Convert.ToInt32(row.Cells[2].Text);
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question