Solved

ItemTemplate (Menu)

Posted on 2007-03-19
9
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to dynamically set the form action using jQuery.

739 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