nested Gridview overflows DIV size

Discussion in 'ASP .Net Web Controls' started by Abhijit, Oct 17, 2007.

  1. Abhijit

    Abhijit Guest

    Strange behavior with ASP.NET 2.0

    I have a simple nested gridview (for sample, each with just two columns)

    The gridview is placed inside a DIV which has height fixed and "overflow =
    auto" to control the flow of contents inside DIV and show scrollbars
    automaticallty.

    The parent GRIDVIEW gets clipped correctly but the child one keeps rendering
    outside the DIV bounds

    Here is the sample ASPX (ignoring other obvious stuff)
    I don't know if I can attach an screenshot to demonstrate the problem.

    /////// ASP ////////////////
    .......
    <div style="height:100px;overflow:auto;">
    <asp:GridView id="GV_Parent" ......>
    <asp:BoundField DataField="ParentVal1" />
    <asp:TemplateField HeaderText="" ShowHeader="False">
    <ItemTemplate>
    <asp:GridView id="GV_Child" ....
    <asp:BoundField DataField="ChildVal1" />
    </ItemTemplate>
    </asp:TemplateField>
    </asp:GridView>
    </div>
    ............
    /////////////// C# CodeBehind ////////////////
    /////// Ignoring other stuff ////////////

    public class myDataChild
    {
    private int iVal;
    public int ChildVal1
    {
    get { return iVal; }
    set { iVal = value; }
    }

    }
    public class myDataParent
    {
    private int iVal;
    public List<myDataChild> iChildList ;
    public int ParentVal1
    {
    get { return iVal; }
    set { iVal = value; }
    }

    }

    public partial class MyPage : System.Web.UI.Page
    {
    List<myDataParent> DataForBinding = new List<myDataParent>();
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    for(int iC = 0; iC < 30; iC++)
    {
    myDataParent item = new myDataParent ;
    item.ParentVal1 = iC ;
    for(int jC = 0; jC < 2; jC++)
    {
    myDataChild chItem = new myDataChild ;
    chItem.ChildVal1 = jC ;
    item.Add(chItem) ;
    }
    DataForBinding.Add(item);
    }
    GV_Parent.DataSource = DataForBinding;
    GV_Parent.DataBind();
    }
    }

    protected void gv_RowDataBound........
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    myDataParent pData = (myDataParent)e.Row.DataItem;
    GridView gv = (GridView)e.Row.FindControl("GV_Child");
    if (null != gv)
    {
    gv.DataSource = pData.iChildList;
    gv.DataBind();
    }
    }
    }
    }
    ///////////////////////
     
    Abhijit, Oct 17, 2007
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karthik
    Replies:
    3
    Views:
    1,015
    Karthik
    Aug 13, 2004
  2. =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=

    Fallback for indent aligned table that overflows?

    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jun 28, 2006, in forum: XML
    Replies:
    2
    Views:
    417
    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=
    Jul 4, 2006
  3. Chris
    Replies:
    2
    Views:
    11,905
    Bergamot
    Sep 28, 2006
  4. MWB

    Dealing with possible overflows

    MWB, Aug 2, 2004, in forum: C Programming
    Replies:
    2
    Views:
    411
    Michael Mair
    Aug 2, 2004
  5. Jimmy
    Replies:
    7
    Views:
    5,300
    Chaddy2222
    Nov 21, 2008
  6. K Viltersten

    <div ... /> and <div ...></div>

    K Viltersten, Mar 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    1,097
  7. Dwayne Madsen

    Q: Div A inside Div B is larger than Div B

    Dwayne Madsen, Jun 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    442
    David Dorward
    Jun 1, 2005
  8. mscir
    Replies:
    3
    Views:
    535
    Martin Honnen
    Jun 26, 2005
Loading...