OnBubbleEvent with Button (child control) in GridView (parent control)

I have a button (created at runtime) inside the gridview.  I'm having a hard time telling the grid view that row 1 (the row which was selected when the button is clicked) is selected. Here's my code so far:


        protected void ContentsGrid_RowCreated(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                //Display Imagebutton for View in column 1
                ImageButton imgView = new ImageButton();
                imgView.ID = "imgView" + counter;
                imgView.ToolTip = "View " + imgView.ID;
                imgView.ImageUrl = @"~/Images/magnify2.bmp";

                //Display Imagebutton for Copy in column 2
                ImageButton imgCopy = new ImageButton();
                imgCopy.ID = "imgCopy" + counter;
                imgCopy.ToolTip = "Copy " + imgCopy.ID;
                imgCopy.ImageUrl = @"~/Images/copy.jpg";
                imgCopy.CommandName = "Copy";
                //imgCopy.Command += new CommandEventHandler(imgCopy_Command);

                //Display Checkbox in column 3
                CheckBox chkItem = new CheckBox();
                chkItem.ID = "Checkbox1";

       protected override bool OnBubbleEvent(object source, EventArgs args)
            bool isHandled = false;
            if (args is CommandEventArgs)
                CommandEventArgs ce = (CommandEventArgs)args;
                if (ce.CommandName)
                    //I don't know what to do here... T_T
            return isHandled;
            //return base.OnBubbleEvent(source, args);

        protected virtual void OnCommand(object sender, CommandEventArgs e)
            foreach (GridViewRow item in ContentsGrid.Rows)
                Response.Write("Copied" + item.Cells[controls + 3].Text);

            //throw new NotImplementedException();

  Any suggestions here? This is quite new to me... Crying

Web developer by day My programming blog,

Musician by night Musician's blog.
9/18/2008 6:43:19 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 8

Hi Musikero11 ,

From your code, I guess you are create one costom GridView control. I can't give you full code ,but I can share my idea.

So first of all , you'd better to set the button's CommandName equals "Select" , then .

I will do it this way:


        protected override bool OnBubbleEvent(object source, EventArgs e)
            bool handled = false;
            GridViewCommandEventArgs args = e as GridViewCommandEventArgs;

            if (e is CommandEventArgs)
                CommandEventArgs ce = (CommandEventArgs)e;
                if (ce.CommandName == "Select")¡¡
                    this.HandleSelect(this.GetRowIndex(args.Row, (string) args.CommandArgument));

                    handled = true;
            return handled;

 And one good practice is to use Reflector.exe to see the source code of GridView control . You can see how to do this from there .


Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
9/22/2008 2:50:45 AM

Similar Artilces:

Calendar Control inside Repeater, Handling Child control events in parent Data Control
Hi all,I've been researching a problem i have for a couple of days now and i'm still not sure how to even start to handle it.I'm essentially trying to build a page that will display custom form fields/controls for individual items/rows inside a repeater.I've got a fairly complex calendar i need to have working inside each individual row of the Repeater. The calendar is set up to fire the following events: OnDayRender="Calendar2_DayRender" OnSelectionChanged="Calendar2_SelectionChanged" OnVisibleMonthChanged="Calendar2_VisibleMonthChanged"My first question is how do i go about handling these...

how to trigger child control to parent control?
Hi,          I have a issue regarding triggering the child control and the Parent control. Child control here is gridview control and parent control is Repeater control .I need to update columns in Repeater control when update button is clicked in child control i.e Grid view control.How to do that? Does anyone have any ideas.That will be appreciated.One more important thing is Repeater control and gridview control is in a Update panel (Ajax)  Please tell me how to do it? Thanks Look at RaiseBubbleEvent/ObBubbleEvent. Andrey Dudarev...для нас ...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

Make panel in parent user control visible from child user control button click
I have a user control (parent) that have another user control (child) in itself. I also have an invisible panel in the parent. when I click a button in the child user control, I want the child to turn invisible and the panel in the parent user control to be visible. Because the Page_load is activated before Sub Button_Clicked I don't know how to handle this. I use properties to communcate between the controls. My last try: Public Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Click.Click 'Hide this child...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Call a method of parent control from child control
I have a web user control nested within another web user control. How can i call a method of the parent user control from the code behind of the child user control? (c#)thanks   Hi,Can you be more specific? Have you build a composite control? If you've built to controls and placed one inside the other in the aspx page then you can't do what you're asking - the child would need to inherit from the parent control.Might help if we can see some code.Cheers,Matt -- Please mark answers as answers! ---- "SQL has driven more programmers mad than any other ...

how to Call parent control method from child control
Hi all,I have created a control which i have placed in a web form.........the control has a textbox control with a text_changed event hadler.....that is fired after some value is changed in it ..... in that event i set a public property which i access in the parent page's load event to access the entered value in that child control's textbox......the problem is that the events are not fired as i thought..... child control's text_change is fired after main page's load event in postback or initial load.... so the value that i set in textbox text_change event is not accessible in main page's lo...

How do I manipulate a parent control from a child user control?
Hi, In my ASP.NET page, I have a MultiView control which resides within an UpdatePanel. Within the MultiView, I have two user controls. By default, I display the first user control which displays items in my library. If user clicks a button, it displays the second user control which allows user to make a new entry into the library. What I want to do is, once the entry is made, I want to set the ActiveViewIndex to 0 again so that I can display the library again. How can I control the parent MultiView control from my code in the user control? Or is there a better approach to this problem? H...

how to bubble event from child control to parent control?
Hi       I have 2 child controls (GridView Control,Repeater Control) and have 1 parent control (repeater control). Flow is child grid view controlis inside child repeater control and these two child controls are inside the Parent repeater control.All these 3 are in Update Panel How to bubble Rowupdated event from child gridview to parent Repeater control inorder to update columns in Repeater control when update is clicked or is there anyother approach other than bubblevent inorder to Update columns in Parent Repeater control when (Show Edit Button --- Comman...

this.Controls.Add does not add control to child collection (this.Controls.Count == 0)
Ok, as silly as it may sound, I have a situation where I am creating a CompositeControl in ASP.NET 2.0, C#. I have the following code in the CreateChildControls() method that build the control's child control collection: 1    for (int i = 0; i < _menus.Count; i++)2    this.Controls.Add(_menus[i]);3    4    foreach (FloatingMenu menu in _menus)5    {6    Label lbl = new Label();7    lbl.ID = string.Concat("GroupQ", menu.ID);8    lbl.CssClass = "menuIt...

Calling Parent WebUser Control from Child User Control
  Hai..        I have a Small problem please look here..      I have two user controls one is Parent.ascx and Child.ascx.Parent.ascx contains one DataList which binds Employee List from SQL Server or Any DataBase.Child.ascx contains Employee Details which i am going to add .The Parent.ascx is registered in Home.aspx.Child.ascx was registered in Parent.ascx and the child.ascx was calling with a Ajax modal  pop up from the Parent.ascx.While  entering the details in Child.ascx when i click on ADDDetails button in Child.ascx.The deta...

Web resources about - OnBubbleEvent with Button (child control) in GridView (parent control) - asp.net.presentation-controls

RaiseBubbleEvent(Me, args) Protected Overrides Function OnBubbleEvent(ByVal - Pastebin.com
Pastebin launched a little side project called HostCabi.net , check it out ;-) Don't like ads?

Resources last updated: 12/17/2015 8:44:59 PM