简体   繁体   English

内部网格未在嵌套gridview中显示数据

[英]Inner grid is not displaying data in nested gridview

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

<script type="text/javascript" language="javascript">

    function divexpandcollapse(divname) {
        var div = document.getElementById(divname);
        var img = document.getElementById('img' + divname);
        if (div.style.display == "none") {
            div.style.display = "inline";
            img.src = "../kjl_images/closed.gif";
        } else {
            div.style.display = "none";
            img.src = "../kjl_images/open.gif";
        }
    }
</script>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<div>
 <asp:GridView ID="gvParentGrid" runat="server" DataKeyNames="hatchid"
Width="300"AutoGenerateColumns="false"
OnRowDataBound="gvUserInfo_RowDataBound"  GridLines="None"
BorderStyle="Solid" BorderWidth="1px" BorderColor="#df5015">           
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("hatchid") %>');">
<img id="imgdiv<%# Eval("hatchid") %>" width="9px" border="0" 
 src="../kjl_images/closed.gif"  alt="" />
 </a>
 </ItemTemplate>
</asp:TemplateField>
 <asp:BoundField DataField="hatchid" HeaderText="Hatch ID" />
 <asp:BoundField DataField="hatcheryname" HeaderText="Hatchery Name" />                
  <asp:TemplateField>
    <ItemTemplate>
       <tr>
         <td colspan="100%">
 <div id="div<%# Eval("hatchid") %>" style="display: none;
position: relative; left:  15px;   overflow: auto">
asp:GridView ID="gvChildGrid" runat="server"
AutoGenerateColumns="false" BorderStyle="Double"   
BorderColor="#df5015" GridLines="None" Width="250px">                                        
<Columns>
 <asp:BoundField DataField="hatchid" HeaderText="Region"/>                                            
<asp:BoundField DataField="name" HeaderText="Name"/>
   </Columns>
     </asp:GridView>
        </div>
            </td>
               </tr>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</div>

here .CS code 这里.CS代码

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

    }

}

public void FillHatcheryGridDetails()
{
    DataTable dthatcherygrid = new DataTable();
    dthatcherygrid = objhatcheryBAL.GetChickGridsdet();
    gvParentGrid.DataSource = dthatcherygrid;
    gvParentGrid.DataBind();
}

 protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        GridView GridView2 = (GridView)e.Row.FindControl("gvChildGrid");
        int hatchid = Convert.ToInt16(e.Row.Cells[1].Text);
        DataTable dtRegions = new DataTable();
        objhatcheryPL.hatchid = hatchid;
        dtRegions = objhatcheryBAL.GetHatchidDetaisl(objhatcheryPL);
        GridView2.DataSource = dtRegions;
        GridView2.DataBind();
    }
}

I tried every thing i searched in google the code iam posting is from google . 我尝试了我在Google中搜索的所有内容,而IAM发布的代码均来自google。 My problem is inner grid is displaying blank when i clicked the menu button. 我的问题是,当我单击菜单按钮时,内部网格显示空白。 (even with my code also).Can any one say where did I went wrong. (甚至还有我的代码)。任何人都可以说我在哪里出错了。

changed div.style.display = "inline"; 更改了div.style.display =“ inline”; to div.style.display = "block"; 到div.style.display =“ block”;

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

<script type="text/javascript" language="javascript">

function divexpandcollapse(divname) {
    var div = document.getElementById(divname);
    var img = document.getElementById('img' + divname);
    if (div.style.display == "none") {
        div.style.display = "block";
        img.src = "../kjl_images/closed.gif";
    } else {
        div.style.display = "none";
        img.src = "../kjl_images/open.gif";
    }
}
</script>

I had to change from div.style.display = "inline"; 我不得不从div.style.display = "inline"; to div.style.display = "inline-table"; div.style.display = "inline-table"; because div was not keeping width value with divexpandcollapse function 因为div没有使用divexpandcollapse函数保留宽度值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM