Click here to Skip to main content
15,912,207 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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!


XML
<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
Updated 15-Sep-12 6:07am
v8
Comments
[no name] 15-Sep-12 10:45am    
"Lbtn_cash_Shipper_ModalPopupExtender"... "Lbtn_cash_Shipper_ModalPopupExtender12"... hmmm well do you something wrong with this?
Hesha 15-Sep-12 11:13am    
problem is" this.findcontrol" not recognized the control in the item template model popup extender...
[no name] 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 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 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 :(

try this:
HTML
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();
           }


       }
 
Share this answer
 
Comments
Hesha 15-Sep-12 7:53am    
hm...not Working buddy! Same error! object reference is NULL!
prashant patil 4987 15-Sep-12 8:13am    
hey use ModalPopupExtender outside Grid View.
then it will get ModalPopupExtender ID.
Hesha 15-Sep-12 9:07am    
No buddy it also not worked.dnt know why!
//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();
            }
 
        }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900