如何将gridview模板字段设置为模式弹出窗口扩展程序的目标控件?-(问题-Ajax PopupExtender ID无法识别!) [英] How to set gridview template field as target control for modal popup extender?-(Problem -Ajax PopupExtender ID Not recognizing!)

查看:55
本文介绍了如何将gridview模板字段设置为模式弹出窗口扩展程序的目标控件?-(问题-Ajax PopupExtender ID无法识别!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我只想通过模型弹出扩展程序的ID查找控件.但是我使用的方法始终返回Null值.实际上,弹出扩展程序位于网格视图的模板字段之一中,如下所示!


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''是ajaxpopupextender的虚拟控件.//之所以设置它,是因为否则不会触发特定的网格图像imageButton(IBtnPODinfo)的click事件,并且通过将其设置为虚拟控件可以触发gridbutton.(然后我设置了扩展器如下手动弹出.)

我已经导入了Ajax工具包作为参考.





''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();
           }


       }



并且它返回NULL值.那么有人可以帮我解决这个问题吗?



PS:我将modelpopup扩展器设置为虚拟模型,因为否则将不触发网格视图的图像按钮模板!(不发生回发),并手动设置ajax弹出窗口以在Imagebtn Click事件中显示并尝试.然后我意识到gridviews所选的行返回NULL值.然后我将select命令添加到gridview并自行选择Gridview,然后单击Imagebutton,然后它获得了该行并识别了模型弹出窗口并起作用了.不是我想要的.我希望用户单击该图像btn并使用该垂直网格视图传递值(gridview应该将其单元格值之一传递给弹出面板)弹出模型.将值传递给panal是可以的.因为"this.findControl"方法不起作用
代码:
扩展程序= this.FindControl("Lbtn_cash_Shipper_ModalPopupExtender")as ModalPopupExtender;

要求:我需要的是将Gridview的特定单元格值(不需要选择该行,而是将图像按钮的相关行的单元格值传递给),以弹出扩展程序Label,然后将弹出窗口显示为用户.

E.X:gridview1.SelectedRow.cells [2] .value;或gridview1.Rows [i] .cells [2] .value等.

在此先感谢!!!



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 !!!

推荐答案

尝试一下:
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();
           }


       }


//我解决了这个问题……我只需要先通过编码选择gridview行,然后再插入控件即可.就是这样!! !!
代码如下!
//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();
            }
 
        }


这篇关于如何将gridview模板字段设置为模式弹出窗口扩展程序的目标控件?-(问题-Ajax PopupExtender ID无法识别!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆