Solved

ItemTemplate (Menu)

Posted on 2007-03-19
9
512 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 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