在gridview选择行单击后,Ajax ModalPopupExtender不会隐藏 [英] Ajax ModalPopupExtender not hiding after gridview selected row click

查看:62
本文介绍了在gridview选择行单击后,Ajax ModalPopupExtender不会隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我需要从Entry表格中查看POPUP窗口中表格的记录当我们从下拉列表中选择一个特定的客户端时,Gridview Populate.On选择一行,记录填写在Entry上。



我的代码如下:





.aspx: -



Hi,


I have a requirement where I need to view records of a table in a POPUP window from an Entry form.When we select a particular client from dropdownlist, the Gridview Populates.On selecting a row, the records populate on Entry from.

my code is below:


.aspx:--

<body>
    <form id="form1"  runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        
 
    <asp:UpdatePanel ID="UpdatePanel2" runat="server"  UpdateMode ="Always" >
    <contenttemplate>
    
    <div>
       <table>
       <tr>
       <td>Enter Name</td>
       <td>
        <asp:TextBox ID="txtname" runat="server" Height ="30px" Width ="200px" Font-Size ="15px" 

            Font-Names ="Tahoma" CssClass="lowercase" >
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError ="true"  ControlToValidate ="txtname" ValidationGroup ="vg1"   ErrorMessage="Fields Required<br />Name Required"  Display="None" >
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" HighlightCssClass ="validatorCalloutHighlight" runat="server" TargetControlID ="RequiredFieldValidator1">
         <animations>
        <onshow>
        <sequence>
        <hideaction visible="true" />
        <fadein duration="1" minimumopacity="0" maximumopacity="1" />
        </sequence>
        </onshow>
        <onhide>
        <sequence>
        <fadeout duration="1" minimumopacity="0" maximumopacity="1" />
        <hideaction visible="false" />
        </sequence>
        </onhide>
    </animations>
        
        </td>
    </tr>
    <tr>
    <td class="requiredFields ">Address</td>
    <td>
        <asp:TextBox ID="txtaddress" runat="server" Height ="30px" Width ="200px" Font-Names ="Tahoma" Font-Size ="15px">
         <asp:RequiredFieldValidator ID="RFVadd" runat="server" SetFocusOnError ="true"  ControlToValidate ="txtaddress" ValidationGroup ="vg1"   ErrorMessage="Fields Required<br />Name Required"  Display="None" >
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender4" WarningIconImageUrl ="~/Images/red-skull-md.png" HighlightCssClass ="validatorCalloutHighlight" runat="server" TargetControlID ="RFVadd">
         <animations>
        <onshow>
        <sequence>
        <hideaction visible="true" />
        <fadein duration="1" minimumopacity="0" maximumopacity="1" />
        </sequence>
        </onshow>
        <onhide>
        <sequence>
        <fadeout duration="1" minimumopacity="0" maximumopacity="1" />
        <hideaction visible="false" />
        </sequence>
        </onhide>
    </animations>
        
        
        </td>
    </tr>
    <tr>
    <td class="requiredFields">Contact No</td>
    <td>
        <asp:TextBox ID="txtcontactno" runat="server" Height ="30px" Width ="200px" Font-Names ="Tahoma" Font-Size ="15px">
        <asp:RequiredFieldValidator ID="RFVContactNo" runat="server" ControlToValidate ="txtcontactno" SetFocusOnError ="true"   Display="None" ValidationGroup ="vg1"   ErrorMessage="Fields Required<br />Email Id Required">
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender3" runat="server" WarningIconImageUrl ="~/Images/icon-warning1.png" HighlightCssClass ="validatorCalloutHighlight"   TargetControlID ="RFVContactNo" >
        <animations>
        <onshow>
        <sequence>
        <hideaction visible="true" />
        <fadein duration="1" minimumopacity="0" maximumopacity="1" />
        </sequence>
        </onshow>
        <onhide>
        <sequence>
        <fadeout duration="1" minimumopacity="0" maximumopacity="1" />
        <hideaction visible="false" />
        </sequence>
        </onhide>
    </animations>
        
        
        </td>
    </tr>


    <tr>
    <td class="requiredFields">Email</td>
    <td>
        <asp:TextBox ID="txtemail" runat="server" Height ="30px" Width ="200px" Font-Size ="15px"  Font-Names ="Tahoma">
        <asp:RequiredFieldValidator ID="RFVEmail" runat="server" ControlToValidate ="txtemail" SetFocusOnError ="true"   Display="None" ValidationGroup ="vg1"   ErrorMessage="Fields Required<br />Email Id Required">
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" WarningIconImageUrl ="~/Images/red-skull-md.png" HighlightCssClass ="validatorCalloutHighlight"   TargetControlID ="RFVEmail" >
        <animations>
        <onshow>
        <sequence>
        <hideaction visible="true" />
        <fadein duration="1" minimumopacity="0" maximumopacity="1" />
        </sequence>
        </onshow>
        <onhide>
        <sequence>
        <fadeout duration="1" minimumopacity="0" maximumopacity="1" />
        <hideaction visible="false" />
        </sequence>
        </onhide>
    </animations>
        
        </td>
    </tr>

    
    <tr>
    <td class="requiredFields">Fax</td>
    <td>
        <asp:TextBox ID="txtfax" runat="server" Height ="30px" Width ="200px" Font-Names ="Tahoma" Font-Size ="15px">
        <asp:RequiredFieldValidator ID="RFVFax" runat="server" SetFocusOnError ="true"  ControlToValidate ="txtfax" ValidationGroup ="vg1"   ErrorMessage="Fields Required<br />Name Required"  Display="None" >
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" HighlightCssClass ="validatorCalloutHighlight" runat="server" TargetControlID ="RFVFax">
         <animations>
        <onshow>
        <sequence>
        <hideaction visible="true" />
        <fadein duration="1" minimumopacity="0" maximumopacity="1" />
        </sequence>
        </onshow>
        <onhide>
        <sequence>
        <fadeout duration="1" minimumopacity="0" maximumopacity="1" />
        <hideaction visible="false" />
        </sequence>
        </onhide>
    </animations>
        
        
        </td>
    </tr>
    <tr>
        <td class="requiredFields">
            A/C Head
        </td>
        <td>
             <asp:DropDownList ID="ddlaccode" runat="server" CssClass ="ddl ">
        <asp:ListItem Text ="Select" Value ="0">
        
        
        </td>
    </tr>
    <tr>
        <td colspan="2" id="msg"  runat="server" class="msgstyle">
            
        
    </tr>

       
       </table>
      <asp:Button ID="btnview" runat="server" Text="Button" />
    </div>
    <div>
       
         <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow ="true"  

        DynamicServicePath="" Enabled="True" TargetControlID="btnview" cancelcontrolid="ImageButton1" okcontrolid="btnOkay" OnOkScript ="ok()"

	 popupcontrolid="Panel2"  

	popupdraghandlecontrolid="PopupHeader" drag="true" 

	backgroundcssclass="ModalPopupBG">
        
              <asp:Panel ID="Panel2" runat="server" style="display: none">
               
                 
             
	<div class="HellowWorldPopupmore">

               
                <div style=" max-width : 950px; font-family : Tahoma ;font-weight :200 ;">
         <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode ="Conditional" >
        <contenttemplate>
         <table>
         <tr>
         <td id="hdr">
                 style =" height : 35px; font-size :large ; color :Purple ; font-weight :bold ; border-bottom-color :Aqua ; border-bottom-style :solid ; border-bottom-width : 1px;">
<div style="float :right ;">         <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl ="~/clzo.jpg" CssClass ="cls"    /></div>
         </td>
         
         </tr>
         <tr>
         <td>
             <asp:DropDownList ID="ddlclub" runat="server" OnSelectedIndexChanged ="ddlclub_SelectedIndexChanged" AutoPostBack ="true" >
             
         </td>
         </tr>
         <tr>
         <td>

             <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false" onrowcreated="GridView1_RowCreated" 

                    onrowdatabound="GridView1_RowDataBound" 

                    onselectedindexchanged="GridView1_SelectedIndexChanged" 

            DataKeyNames="code" >
                <columns>
                 <asp:BoundField DataField="code" HeaderText="code"   

                     ReadOnly="True" SortExpression="code" />
                     <asp:BoundField DataField="clubname" HeaderText="clubname"   

                     ReadOnly="True" SortExpression="clubname" />
                     <asp:BoundField DataField="Add1" HeaderText="Address"   

                     ReadOnly="True" SortExpression="Add1" />
                      
                 <asp:BoundField DataField="Phone" HeaderText="Phone" 

                     SortExpression="Phone" />
                 <asp:BoundField DataField="FAX" HeaderText="FAX" 

                     SortExpression="FAX" />
                 <asp:BoundField DataField="Email" HeaderText="Email"   

                     ReadOnly="True" SortExpression="Email" />
                       <asp:BoundField DataField="Accode" HeaderText="Accode"   

                     ReadOnly="True" SortExpression="Accode" />
                       <asp:BoundField DataField="UserCd" HeaderText="UserCd"   

                     ReadOnly="True" SortExpression="UserCd" />
                 
                     
                 
             </columns>
             
         </td> 
         </tr>
         </table> 
         </contenttemplate>
     <triggers>
     
     <asp:AsyncPostBackTrigger ControlID ="ddlclub" EventName ="SelectedIndexChanged" /></triggers>
      
         <div class="clear"> </div>
                </div>
                <div>
                    <input id="btnCancel" type="button" value="Close" style =" border-style :none ; background-color :White ; display :none ;" />
                    <input id="btnOkay" type="button" value="" style =" border-style :none ; background-color :White ; display : none ;"   />
                    
		</div>
        
        </div> 
    
       
    
       
    
       </div>
       </contenttemplate>
       <triggers>
        <asp:AsyncPostBackTrigger ControlID ="ddlclub" EventName ="SelectedIndexChanged" /></triggers>
            
    
    </form>
</body>







.cs code:---






.cs code:---

protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           bindclub();
       }
   }

   protected void bindclub()
   {
       con.Open();

       SqlCommand cmd;
       try
       {
           cmd = new SqlCommand("Select code,clubname from club", con);
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataTable dt = new DataTable();
           da.Fill(dt);
           ddlclub.DataValueField = "code";
           ddlclub.DataTextField = "clubname";
           ddlclub.DataSource = dt;
           ddlclub.DataBind();

       }
       catch (Exception ex)
       {

       }
       finally
       {
           con.Close();
       }

   }


   protected void bindgrid()
   {
       con.Open();
       SqlCommand com;
       try
       {
           com = new SqlCommand("Select * from Club where code='" + ddlclub .SelectedValue  + "' ", con);
           SqlDataAdapter daa = new SqlDataAdapter(com);
           DataTable dtt = new DataTable();
           daa.Fill(dtt);
           GridView1.DataSource = dtt;
           GridView1.DataBind();
       }
       catch (Exception ex)
       {
           con.Close();
       }
   }
   protected void ddlclub_SelectedIndexChanged(object sender, EventArgs e)
   {
       bindgrid();
       ModalPopupExtender1.Show();
       UpdatePanel1.Update();
   }

   protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           e.Row.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex.ToString()));
           e.Row.Style.Add("cursor", "pointer");
       }
   }
   protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       e.Row.Cells[0].Visible = false;
     //  e.Row.Cells[1].Visible = false;
      // e.Row.Cells[2].Visible = false;
      // e.Row.Cells[5].Visible = false;
   }
   protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {


       ViewState["code"] = GridView1.SelectedRow.Cells[0].Text; ;



   }







The Problem is that, after we select a Grid row, all the records populate as intended but the popup window in freezed at the fag end of the page.





Please help....




The Problem is that, after we select a Grid row, all the records populate as intended but the popup window in freezed at the fag end of the page.


Please help....


推荐答案

\" + e.Row.RowIndex.ToString()));
e.Row.Style.Add(\"cursor\", \"pointer\");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
// e.Row.Cells[1] .Visible = false;
// e.Row.Cells[2].Visible = false;
// e.Row.Cells[5].Visible = false;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{


ViewState[\"code\"] = GridView1.SelectedRow.Cells[0].Text; ;



}
" + e.Row.RowIndex.ToString())); e.Row.Style.Add("cursor", "pointer"); } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; // e.Row.Cells[1].Visible = false; // e.Row.Cells[2].Visible = false; // e.Row.Cells[5].Visible = false; } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { ViewState["code"] = GridView1.SelectedRow.Cells[0].Text; ; }







The Problem is that, after we select a Grid row, all the records populate as intended but the popup window in freezed at the fag end of the page.





Please help....




The Problem is that, after we select a Grid row, all the records populate as intended but the popup window in freezed at the fag end of the page.


Please help....



Why not just call ModalPopupExtender1.Hide() in your SelectedIndexChanged event handler of the gridview?



Why not just call ModalPopupExtender1.Hide() in your SelectedIndexChanged event handler of the gridview?

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
      ViewState["code"] = GridView1.SelectedRow.Cells[0].Text; ;
      ModalPopupExtender1.Hide();
 }


这篇关于在gridview选择行单击后,Ajax ModalPopupExtender不会隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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