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. Advertising

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:
    925
    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:
    354
    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=
    Jul 4, 2006
  3. MWB

    Dealing with possible overflows

    MWB, Aug 2, 2004, in forum: C Programming
    Replies:
    2
    Views:
    320
    Michael Mair
    Aug 2, 2004
  4. Andre Majorel

    Detecting overflows while computing off_t

    Andre Majorel, Dec 22, 2006, in forum: C Programming
    Replies:
    6
    Views:
    391
    Andre Majorel
    Dec 24, 2006
  5. Robert J. Hansen

    stringstream str(), buffer overflows

    Robert J. Hansen, Feb 9, 2006, in forum: C++
    Replies:
    12
    Views:
    927
    Dietmar Kuehl
    Feb 11, 2006
Loading...

Share This Page