使用垂直滚动条数据库gridview

时间:2023-01-29 21:12:09

i have some long data in my gridview and need a scrollbar (to the gridview). try few ways - non of them works. i guess because the postback or the databind..

我在gridview中有一些长数据,需要一个scrollbar(到gridview)。尝试一些方法——没有一种是有效的。我猜是因为回发或数据库。

the asp.net code:

asp.net代码:

<asp:GridView ID="gvGuess" runat="server" AllowSorting="True" OnSorting="gridView_Sorting" OnRowCreated="GridView1_RowCreated" OnRowDataBound="gvGuess_RowDataBound" Style="top: 301px; left: 212px; direction: rtl; overflow:scroll; position: absolute; height: 176px; width: 359px" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="None">

 <AlternatingRowStyle BackColor="#F7F7F7" />
 <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
 <HeaderStyle BackColor="#4A3C8C" HorizontalAlign="Center" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" HorizontalAlign="Center" ForeColor="#4A3C8C" />
            <SelectedRowStyle BackColor="White" Font-Bold="True" ForeColor="#F7F7F7" />
            <SortedAscendingCellStyle BackColor="#F4F4FD" />
            <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
            <SortedDescendingCellStyle BackColor="#D8D8F0" />
           <SortedDescendingHeaderStyle BackColor="#3E3277" />
        </asp:GridView>

and the c# code:

和c#代码:

    protected void loadGuess()
    {
  noInfo.Visible = false;
  ds = dataFunk.getGuestsgrid(Convert.ToString(Session["orderNum"]),    Convert.ToString(Session["choice"]));
        gvGuess.AutoGenerateColumns = true;
        gvGuess.DataSource = ds;
        gvGuess.DataMember = dataFunk.getGuestsgrid(Convert.ToString(Session["orderNum"]), Convert.ToString(Session["choice"])).Tables[0].ToString();
            gvGuess.DataBind();}

thanks :)

谢谢:)

1 个解决方案

#1


7  

some time ago i stuck at same. I tried a work around and it work for me.

一段时间以前,我也一样。我尝试了一种方法,它对我有用。

Wrap your gridview in a div and give dive a definite height with overflow-y:scroll
something like this

将你的gridview封装在一个div中,用overflowy给潜水一个确定的高度:像这样滚动

<div id="popup" style="max-height:600px;overflow-y:scroll;">
 // Your GridView
</div>

this will work like sliding Gridview. you can give max-height as you like.

这将像滑动Gridview一样工作。你可以根据自己的喜好设定最大高度。

#1


7  

some time ago i stuck at same. I tried a work around and it work for me.

一段时间以前,我也一样。我尝试了一种方法,它对我有用。

Wrap your gridview in a div and give dive a definite height with overflow-y:scroll
something like this

将你的gridview封装在一个div中,用overflowy给潜水一个确定的高度:像这样滚动

<div id="popup" style="max-height:600px;overflow-y:scroll;">
 // Your GridView
</div>

this will work like sliding Gridview. you can give max-height as you like.

这将像滑动Gridview一样工作。你可以根据自己的喜好设定最大高度。