Set Datalist height dynamically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    #1

    Set Datalist height dynamically

    I have a datalist and I want the datalist to grow from no records to fill
    the
    screen, but not go beyond the screen height. How do I do that?
    I've implemented the scroll bars but it works only for the fixed height. I
    want
    the datalist to grow and shrink and never go beyond the current screen
    height, if the data can not fit in one screen I want to implement scroll
    bars, but only scroll the datalist not any other parts.

    Thank You



    Peter


    Here's my code, I've tried adding a table, but still can not get it to work.

    <asp:Panel ID="Panel1" runat="server" height="300px" ScrollBars="Ver tical" >
    <table width="100%" style="border: 1px solid; border-color: Blue"
    border="0" cellpadding="0" cellspacing="0" >
    <tr>
    <td>

    <asp:datalist id="dlTemplateL ist" style="width: 100%;"
    datakeyfield="I temID" runat="server"
    cellpadding="1" OnItemDataBound ="dlTemplateLis t_ItemDataBound ">
    <itemtemplate >
    <table class="datalist style">
    <tr>
    <td valign="top" align="left" style="width:30 px">
    <asp:ImageButto n ID="ImageButton 1" runat="server"
    ImageUrl="~/images/icon_sitelog_16 px.gif"
    onclick="ImageB utton1_Click"/>

    </td>
    <td style="width:32 0px" class="reportna me">
    <asp:HyperLin k ID="HyperLinkRe port" Runat="Server"
    Text='<%# DataBinder.Eval (Container.Data Item, "ObjectName ") %>'
    NavigateUrl='~/DesktopModules/Report/Viewer.aspx?Rep ortID=<%#
    DataBinder.Eval (Container.Data Item, "ItemID") %>'
    Target="_top"
    />

    <asp:Label ID="lblContent1 " runat="server" CssClass="Norma l"/>
    </td>
    <td>
    <span id="spanInModul eB" style="overflow :auto; ">
    <asp:Label ID="Label1" runat="server" CssClass="descr iption"
    Text='<%# DataBinder.Eval (Container.Data Item, "Descriptio n") %>'/>

    </span>
    </td>
    </tr>
    </table>

    </itemtemplate>

    </asp:datalist>



  • Steven Cheng [MSFT]

    #2
    RE: Set Datalist height dynamically

    Hi Peter,

    From your description, you're wantting to make a DataList's height grows
    dynamically and when it reach a certain maxmium limitation make it become
    scrollable, correct?

    As for scrolling datalist, I have a idea that use a <divto wrapper your
    DataList, thus, you can apply style on the DIV so that it will display
    scrollbar when its inner content exceed its height.

    #WWW FAQs: How do I add a scrollbar to part of a page?


    #how to get a scrollbar on a div-section in an html-page?


    And you may need to adjust the div's height according to your current
    page's height. You may consider use client script to get document body
    height. How do you think?

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.

    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.



    --------------------
    >From: "Peter" <czupet@nospam. nospam>
    >Subject: Set Datalist height dynamically
    >Date: Thu, 17 Apr 2008 23:20:15 -0500
    >
    >I have a datalist and I want the datalist to grow from no records to fill
    >the
    >screen, but not go beyond the screen height. How do I do that?
    >I've implemented the scroll bars but it works only for the fixed height.
    I
    >want
    >the datalist to grow and shrink and never go beyond the current screen
    >height, if the data can not fit in one screen I want to implement scroll
    >bars, but only scroll the datalist not any other parts.
    >
    >Thank You
    >
    >
    >
    >Peter
    >
    >
    >Here's my code, I've tried adding a table, but still can not get it to
    work.
    >
    ><asp:Panel ID="Panel1" runat="server" height="300px" ScrollBars="Ver tical"
    >
    ><table width="100%" style="border: 1px solid; border-color: Blue"
    >border="0" cellpadding="0" cellspacing="0" >
    ><tr>
    ><td>
    >
    ><asp:datalis t id="dlTemplateL ist" style="width: 100%;"
    >datakeyfield=" ItemID" runat="server"
    cellpadding="1" OnItemDataBound ="dlTemplateLis t_ItemDataBound ">
    <itemtemplate >
    <table class="datalist style">
    <tr>
    <td valign="top" align="left" style="width:30 px">
    <asp:ImageButto n ID="ImageButton 1" runat="server"
    >ImageUrl="~/images/icon_sitelog_16 px.gif"
    onclick="ImageB utton1_Click"/>
    >
    </td>
    <td style="width:32 0px" class="reportna me">
    <asp:HyperLin k ID="HyperLinkRe port" Runat="Server"
    Text='<%# DataBinder.Eval (Container.Data Item, "ObjectName ") %>'
    NavigateUrl='~/DesktopModules/Report/Viewer.aspx?Rep ortID=<%#
    >DataBinder.Eva l(Container.Dat aItem, "ItemID") %>'
    Target="_top"
    />
    >
    <asp:Label ID="lblContent1 " runat="server" CssClass="Norma l"/>
    </td>
    <td>
    <span id="spanInModul eB" style="overflow :auto; ">
    <asp:Label ID="Label1" runat="server" CssClass="descr iption"
    >Text='<%# DataBinder.Eval (Container.Data Item, "Descriptio n") %>'/>
    >
    </span>
    </td>
    </tr>
    </table>
    >
    </itemtemplate>
    >
    ></asp:datalist>
    >
    >
    >
    >

    Comment

    • Peter

      #3
      Re: Set Datalist height dynamically

      Thank you very much, it works great!


      "Steven Cheng [MSFT]" <stcheng@online .microsoft.comw rote in message
      news:qBtdhRToIH A.4932@TK2MSFTN GHUB02.phx.gbl. ..
      Hi Peter,
      >
      From your description, you're wantting to make a DataList's height grows
      dynamically and when it reach a certain maxmium limitation make it become
      scrollable, correct?
      >
      As for scrolling datalist, I have a idea that use a <divto wrapper your
      DataList, thus, you can apply style on the DIV so that it will display
      scrollbar when its inner content exceed its height.
      >
      #WWW FAQs: How do I add a scrollbar to part of a page?

      >
      #how to get a scrollbar on a div-section in an html-page?

      >
      And you may need to adjust the div's height according to your current
      page's height. You may consider use client script to get document body
      height. How do you think?
      >
      Sincerely,
      >
      Steven Cheng
      >
      Microsoft MSDN Online Support Lead
      >
      >
      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we can improve the support we provide to you. Please
      feel free to let my manager know what you think of the level of service
      provided. You can send feedback directly to my manager at:
      msdnmg@microsof t.com.
      >
      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to
      http://msdn.microsoft.com/subscripti...ult.aspx#notif
      ications.
      >
      =============== =============== =============== =====
      This posting is provided "AS IS" with no warranties, and confers no
      rights.
      >
      >
      >
      --------------------
      >>From: "Peter" <czupet@nospam. nospam>
      >>Subject: Set Datalist height dynamically
      >>Date: Thu, 17 Apr 2008 23:20:15 -0500
      >>
      >>I have a datalist and I want the datalist to grow from no records to fill
      >>the
      >>screen, but not go beyond the screen height. How do I do that?
      >>I've implemented the scroll bars but it works only for the fixed height.
      I
      >>want
      >>the datalist to grow and shrink and never go beyond the current screen
      >>height, if the data can not fit in one screen I want to implement scroll
      >>bars, but only scroll the datalist not any other parts.
      >>
      >>Thank You
      >>
      >>
      >>
      >>Peter
      >>
      >>
      >>Here's my code, I've tried adding a table, but still can not get it to
      work.
      >>
      >><asp:Panel ID="Panel1" runat="server" height="300px" ScrollBars="Ver tical"
      >>
      >><table width="100%" style="border: 1px solid; border-color: Blue"
      >>border="0" cellpadding="0" cellspacing="0" >
      >><tr>
      >><td>
      >>
      >><asp:datali st id="dlTemplateL ist" style="width: 100%;"
      >>datakeyfield= "ItemID" runat="server"
      > cellpadding="1" OnItemDataBound ="dlTemplateLis t_ItemDataBound ">
      > <itemtemplate >
      > <table class="datalist style">
      > <tr>
      > <td valign="top" align="left" style="width:30 px">
      > <asp:ImageButto n ID="ImageButton 1" runat="server"
      >>ImageUrl="~/images/icon_sitelog_16 px.gif"
      > onclick="ImageB utton1_Click"/>
      >>
      > </td>
      > <td style="width:32 0px" class="reportna me">
      > <asp:HyperLin k ID="HyperLinkRe port" Runat="Server"
      > Text='<%# DataBinder.Eval (Container.Data Item, "ObjectName ")
      >%>'
      > NavigateUrl='~/DesktopModules/Report/Viewer.aspx?Rep ortID=<%#
      >>DataBinder.Ev al(Container.Da taItem, "ItemID") %>'
      > Target="_top"
      > />
      >>
      > <asp:Label ID="lblContent1 " runat="server" CssClass="Norma l"/>
      > </td>
      > <td>
      > <span id="spanInModul eB" style="overflow :auto; ">
      > <asp:Label ID="Label1" runat="server" CssClass="descr iption"
      >>Text='<%# DataBinder.Eval (Container.Data Item, "Descriptio n") %>'/>
      >>
      > </span>
      > </td>
      > </tr>
      > </table>
      >>
      > </itemtemplate>
      >>
      >></asp:datalist>
      >>
      >>
      >>
      >>
      >

      Comment

      • Steven Cheng [MSFT]

        #4
        Re: Set Datalist height dynamically

        You're welcome :)

        Sincerely,

        Steven Cheng
        Microsoft MSDN Online Support Lead

        Comment

        Working...