展开和折叠后,加号和减号图像不会显示在嵌套网格中 [英] Plus and minus image is not showing in nested grid after expanding and collapsing

查看:98
本文介绍了展开和折叠后,加号和减号图像不会显示在嵌套网格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......代码工作正常......每当我点击+图像时,它都会扩展子网格。



但是一旦页面被加载就会出现问题在查看按钮之后....加号图像显示...在展开网格后它没有显示负图像,如果我正在折叠图像没有回到正图像...它显示为不支持的图像..



可以提供任何解决方案......



这是我的代码....



我尝试过:



Hi...The code is working fine.. whenever I'm clicking + image it's expanding child grid.

But the problem once the page is loaded after view button....the plus image is showing... after expanding the grid it is not displaying the minus image and again if i'm collapsing the image is not back to plus image... It's displaying like not supported images..

Can any give solution...

This is My code....

What I have tried:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>










<script type="text/javascript">
    $("[src*=plus]").live("click", function () {
        $(this).closest("tr").after("<tr><td></td><td >" + $(this).next().html() + "</td></tr>")
        $(this).attr("src", "~/Images/minus.png");
    });
    $("[src*=minus]").live("click", function () {
        $(this).attr("src", "~/Images/plus.png");
        $(this).closest("tr").next().remove();
    });
</script>







ASP代码








ASP CODE


<asp:GridView ID="GvDetailPrimary" runat="server" AutoGenerateColumns="false" DataKeyNames="UHIDNO"
             CssClass="table table-striped table-bordered table-hover" EditRowStyle-HorizontalAlign="Center" OnRowDataBound="gvDetailReport_rowdatabound">

           <Columns>

               <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center" >
                <ItemTemplate>

                    <asp:Image ID="img_expand" runat="server" style="cursor: pointer" ImageUrl="~/Images/plus.png" />
                    <asp:Panel ID="pnldepend" runat="server" Style="display: none">

                      <asp:GridView ID="GvDetailDepend" runat="server" AutoGenerateColumns="false" CssClass = "table table-striped table-bordered table-hover">
                           <Columns>
                                 <asp:TemplateField HeaderText="Dependents" Visible="TRUE" ItemStyle-HorizontalAlign="Center" >
                                 <ItemTemplate>
                                      <asp:Label ID="lbldepname" runat="server" Text='<%#Eval("Membername") %>' Width="20%" align="center"></asp:Label>
                                 </ItemTemplate>
                                 </asp:TemplateField>

                                 <asp:TemplateField HeaderText="Age" Visible="TRUE" ItemStyle-HorizontalAlign="Center" >
                                 <ItemTemplate>
                                      <asp:Label ID="lbldepage" runat="server" Text='<%#Eval("age") %>' Width="20%" align="center"></asp:Label>
                                 </ItemTemplate>
                                 </asp:TemplateField>

                             </Columns>
                          </asp:GridView>

                      </asp:Panel>
              </ItemTemplate>
              </asp:TemplateField>

        <asp:TemplateField HeaderText="UHIDNO" ItemStyle-HorizontalAlign="center">
               <ItemTemplate>
                   <asp:Label ID="lbluhidno" runat="server" Text='<%#Eval("UHIDNO") %>' align="center"></asp:Label>
               </ItemTemplate>
               </asp:TemplateField>
 </Columns>
         </asp:GridView>







onrowdatabound代码落后






Code behind in onrowdatabound

protected void gvDetailReport_rowdatabound(object sender, GridViewRowEventArgs e)
 {
     SqlDataReader objSqlDataReader = null;
     try
     {

         if (e.Row.RowType == DataControlRowType.DataRow)
         {

             Label uhid = (Label)e.Row.FindControl("lbluhidno");

             GridView gridbind = (GridView)e.Row.FindControl("GvDetailDepend");
             objSqlDataReader = SP.DMLQuery_DetailReportDepen(uhid.Text);
             DataTable dt = new DataTable();
             dt.Load(objSqlDataReader);
             if (dt.Rows.Count > 0)
             {
                 gridbind.DataSource = dt;
                 gridbind.DataBind();
             }

         }
     }

     catch (Exception ex)
     {
         oErrorLog.WriteErrorLog(ex.ToString());
     }

  }

推荐答案

([src * = plus] ).live(click,function(){
("[src*=plus]").live("click", function () {


(this).closest(tr)。after(< tr>< td>< / td> ;< td>+
(this).closest("tr").after("<tr><td></td><td >" +


(this).next()。html()+< / td>< / tr>)
(this).next().html() + "</td></tr>")


这篇关于展开和折叠后,加号和减号图像不会显示在嵌套网格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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