Solved

ItemTemplate (Menu)

Posted on 2007-03-19
9
510 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
Comment Utility
either DataKeys or get the value from the cell itself:
MyGridView.SelectedItem.Cells[intIDCellIndex].InnerText
0
 

Author Comment

by:joan2006
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

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

Author Comment

by:joan2006
Comment Utility
:) ... 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
Comment Utility
Can anyone help me with my problem?
0
 

Accepted Solution

by:
joan2006 earned 0 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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