Hi Bob,
I would suggest writing a new render method for your gridview items instead
of using a HTML table.
We had done something similar in ASP.Net 1.1 using a datagrid.

the code we used was something like this:
//first set a new render method
private void dgRoI_ItemCreated(object sender, DataGridItemEventArgs e)
{
            if(ListItemType.Item == e.Item.ItemType ||
ListItemType.AlternatingItem == e.Item.ItemType)
            {
                e.Item.SetRenderMethodDelegate(new
System.Web.UI.RenderMethod(NewRenderMethod_Div));
            }
}

//This is the new render method that we are going to use. In this we use a
class level variable to intRowCounter to keep track of the number of rows we
have render. Only for the first row, (when no rows have been rendered as
yet) create the div and the table.

private void NewRenderMethod_Div(System.Web.UI.HtmlTextWriter writer,
System.Web.UI.Control ctl)
        {
            if(intRowCounter==0)
            {
                writer.Write("<TD colspan=\"11\">");
                writer.Write("<DIV id=\"CombinedDiv\" style=\"OVERFLOW:
auto; overflow-y:scroll; HEIGHT: 250px\">\n");
                writer.Write("<TABLE id=\"DivTbl1\" border=\"1\"
style=\"border-collapse:collapse;\"  bordercolor=\"Black\" cellpadding=\"0\"
cellspacing=\"0\" align=\"left\" >");
                writer.Write("<TR align=\"Center\"
style=\"height:30px;\">");//align="Center" style="height:30px;"
            }

            for(int i=0; i<= ctl.Controls.Count-2; i++)
            {
                ctl.Controls[i].RenderControl(writer);
            }
            intRowCounter+=1;
        }
This will render the datagrid in the format you want. Hope you can adapt
this for ASP.Net2.0 gridview.

regards,
Animesh

On 12/8/06, webmastersam2 <[EMAIL PROTECTED]> wrote:
>
>   --- In [email protected] <AspNet2%40yahoogroups.com>,
> [EMAIL PROTECTED] wrote:
> >
> > Hi all,
> >
> > I have a Gridview on my web page and I use the paging feature.
> But due to user requirements, I need to load all rows into my
> gridview control and instead of paging, allow the user to scroll
> thru the rows. Not to worry, the most rows that can be loaded is
> about 100 so performance is not an issue. I also want to display
> only 10 rows in my gridview at a time. Then I want vertical
> scrollbars to allow the user to go thru these rows. I also want the
> headings to be stationary and not move as the user scrolls. Is this
> possible and if so can someone get me started?
> >
> > Thanks,
> > Bob
> >
> > [Non-text portions of this message have been removed]
> >
>
> Hi Bob,
>
> I don't know if GridView allows you to generate HTML that will to
> that job for you, but I think you will have to do this yourself
> because it is a little tricky.
>
> First, you will need a standard HTML table with 2 rows. The first
> rows (about 20px height) will have the header on it (column names).
> The second one (100% height), will contain a span (or a div as you
> want) that enables overflow with the style="overflow-y: auto;". You
> will then put another HTML table (that has the same number of
> columns as the header have) and make it's width 100%, with no
> height. Then, you will size your column headers the same way you
> size the TDs of your inner-most table, so these 2 tables will seem
> to be in the same table. If you want a tip to be sure the columns
> header are the same height as your inner table, create a javascript
> function that loops throught your headers and dynamically set the
> TD's width to the same value for each column. You can call this on
> body.onload in JS. That way, if you have text in one cell that is
> too long to be displayed, your headers will be adjusted to that.
>
> By doing that you will see a normal HTML table with all your data in
> it (like it is a normal gridview), but, with a vertical scrollbar !
>
> Hope it works you Bob.
>
> WebMasterSam
>
>  
>


[Non-text portions of this message have been removed]

Reply via email to