Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 内部网格未在嵌套的gridview中显示数据_C#_Asp.net_Gridview - Fatal编程技术网

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

C# 内部网格未在嵌套的gridview中显示数据,c#,asp.net,gridview,C#,Asp.net,Gridview,我尝试了我在谷歌搜索的每一件事,iam发布的代码来自谷歌。 我的问题是,当我单击菜单按钮时,内部网格显示为空白。 (即使还有我的代码)。有人能说我哪里出错了吗。更改了div.style.display=“inline”;至div.style.display=“block” protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FillHatcheryGridDetail

我尝试了我在谷歌搜索的每一件事,iam发布的代码来自谷歌。 我的问题是,当我单击菜单按钮时,内部网格显示为空白。
(即使还有我的代码)。有人能说我哪里出错了吗。

更改了div.style.display=“inline”;至div.style.display=“block”

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

函数divexpandcollapse(divname){
var div=document.getElementById(divname);
var img=document.getElementById('img'+divname);
如果(div.style.display==“无”){
div.style.display=“块”;
img.src=“../kjl_images/closed.gif”;
}否则{
div.style.display=“无”;
img.src=“../kjl_images/open.gif”;
}
}

我不得不从
div.style.display=“inline”更改
div.style.display=“内联表格”

由于div没有使用
divexpandcollapse

函数保持宽度值,标题是否显示在内部网格上?@KarlAnderson否,但数据正在进入数据源,将
div.style.display从
inline
更改为
block
,然后是否显示?@KarlAnderson。谢谢你。谢谢你的努力。@KarlAnderson即使去掉它也能工作style=“display:none;我能知道到底发生了什么吗
<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>
 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();
    }
}
<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>