Solved

ItemTemplate (Menu)

Posted on 2007-03-19
9
511 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Icons and Colors for Terms 3 24
C# application error "Parameter Is Not Valid". 3 75
Why Does This Page Not Show Up? 4 22
Replace &lt; with < 14 53
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

937 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now