Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
hi
i just want to find the control by id of the model popup extender.but method i used always returned a Null value.actually popup extender is located at the one of grid view's Template fields as follows!
 

<asp:TemplateField HeaderText="  " ShowHeader="False">
   <ItemTemplate>
        <asp:ImageButton ID="IBtnPODinfo" runat="server" Height="16px"
         ImageUrl="~/Resources/images/search-icon.png" onclick="IBtnPODinfo_Click1"
          TabIndex="1" ToolTip="List POD data" Width="25px" />
 
           <asp:ModalPopupExtender ID="Lbtn_cash_Shipper_ModalPopupExtender" TargetControlID="IBtnPODinfo_dummy"
           PopupControlID="Panel5" CancelControlID="panel1Close" runat="server">
           </asp:ModalPopupExtender>
 
 </ItemTemplate>
</asp:TemplateField>
 

 
'IBtnPODinfo_dummy' is the dummy control for ajaxpopupextender.// i set it because otherwise perticular grid imagebutton(IBtnPODinfo)'s click event is not firing and by setting it to dummy control allows gridbutton to fire.(then i set extender to pop up manually as follows.)
 
i have imported Ajax tool kit as a reference.
 
 protected void IBtnPODinfo1_Click(object sender, ImageClickEventArgs e)
        {
            Lbl_HAWB.Text = "TEST_125_ok";
 
            GridViewRow row = ExtractPODGridView.SelectedRow;
 
           if (row == null) return;
 
            ModalPopupExtender extender = new ModalPopupExtender();
            //extender = this.FindControl("Lbtn_cash_Shipper_ModalPopupExtender") as ModalPopupExtender; 
             extender = row.FindControl("Lbtn_cash_Shipper_ModalPopupExtender") as ModalPopupExtender; 
 

            if (extender != null)
            {
                Panel5.Visible = true;
                extender.Show();
            }
 

        }
 
 
and its returns NULL value.So can someone help me on this matter?
 

 
P.S: i set modelpopup extender to a dummy one because otherwise Image button Template of the grid view is not fired!(postback is not occurred) and set manually ajax popup to show in the Imagebtn Click event.and tried. then i realized that the gridviews selected row is returning NULL value.Then i add select command to a gridview and just Select the Gridview by Itself and then i clicked on the Imagebutton and then it get the row and recognized the modelpopup and worked.but it is not i wanted.i want users to click on that imagebtn and get the model pop up with that perticular gridview passing value( gridview should pass one of its cell value to popup panel.)passing value to the panal is ok.I did this because "this.findControl" method was not worked
Code:
extender = this.FindControl("Lbtn_cash_Shipper_ModalPopupExtender") as ModalPopupExtender;
 
Requirement : what i need is to transfer Gridview's particular cell value (does not need to select the row but to pass relevant row's cell value of the image button ) to popup extender Label and then show the pop up to the users.
 
E.X : gridview1.SelectedRow.cells[2].value; or gridview1.Rows[i].cells[2].value ect.
 
Thanks in Advance !!!
Posted 15-Sep-12 1:30am
Hesha764
Edited 15-Sep-12 6:07am
v8
Comments
Wes Aday at 15-Sep-12 10:45am
   
"Lbtn_cash_Shipper_ModalPopupExtender"... "Lbtn_cash_Shipper_ModalPopupExtender12"... hmmm well do you something wrong with this?
Hesha at 15-Sep-12 11:13am
   
problem is" this.findcontrol" not recognized the control in the item template model popup extender...
Wes Aday at 15-Sep-12 11:17am
   
If you are going to change your "question" around according to some whim then maybe you should start over and tell us exactly what the problem is and the exact code you are working with.
Hesha at 15-Sep-12 11:54am
   
sorry..Now i updated the code above with the explanation.i set modelpopup extender to a dummy one because otherwise Image button Template of the grid view is not fired!(postback is not occurred) and set manually ajax popup to show in the Imagebtn Click event.and tried. then i realized that the gridviews selected row is returning NULL value.Then i add select command to a gridview and just Select the Gridview by Itself and then i clicked on the Imagebutton and then it get the row and recognized the modelpopup and worked.but it is not i wanted.i want users to click on that imagebtn and get the model pop up with that perticular gridview passing value( gridview should pass one of its cell value to popup panel.)passing value to the panal is ok.I did this because "this.findControl" method was not worked
Code:
 
extender = this.FindControl("Lbtn_cash_Shipper_ModalPopupExtender") as ModalPopupExtender;
 
Requirement : what i need is to transfer Gridview's particular cell value (does not need to select row but relevant row of the image button ) to popup extender Label and then show the pop up to the users.
Hesha at 15-Sep-12 11:09am
   
ohh ...no i just made some updowns to the code before copied here.but i put same extender-id in my codes. hm..after that i tried to add again a select Template field and set model pop up extender target control to a dummy control. but still not working it :(
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this:
 protected void IBtnPODinfo1_Click(object sender, ImageClickEventArgs e)
        {
            Lbl_HAWB.Text = "TEST_125_ok";
 
           // GridViewRow row = ExtractPODGridView.SelectedRow;
 
          // if (row == null) return;
 
            ModalPopupExtender extender = new ModalPopupExtender();
            extender = GridView1.Rows.FindControl("Lbtn_cash_Shipper_ModalPopupExtender12") as ModalPopupExtender; 
            if (extender != null)
            {
                Panel5.Visible = true;
                extender.Show();
            }
 
 
        }
  Permalink  
Comments
Hesha at 15-Sep-12 7:53am
   
hm...not Working buddy! Same error! object reference is NULL!
prashant patil 4987 at 15-Sep-12 8:13am
   
hey use ModalPopupExtender outside Grid View.
then it will get ModalPopupExtender ID.
Hesha at 15-Sep-12 9:07am
   
No buddy it also not worked.dnt know why!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

//i solve the problem... i just have to select the gridview row first by coding and then serch the Control.That's it...!!!
Code is as follows!!!
 
GridViewRow clickedRow = ((ImageButton)sender).NamingContainer as GridViewRow;
            ExtractPODGridView.SelectRow(clickedRow.RowIndex);
 
            GridViewRow row = ExtractPODGridView.SelectedRow;
            Lbl_HAWB.Text = row.Cells[1].Text;
 
            if (row == null) return;
 

            ModalPopupExtender extender = new ModalPopupExtender();
            extender = row.FindControl("Lbtn_cash_Shipper_ModalPopupExtender") as ModalPopupExtender;
            if (extender != null)
            {
                Panel5.Visible = true;
                extender.Show();
            }
 
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 375
1 Richard Deeming 240
2 _Amy 205
3 CHill60 195
4 Nirav Prabtani 178
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100