Datagrid problem

S

shruthialekha

I have created a datagrid in visual studio using C#. The dock is set
to none. The datagrid has 4 rows initially and scrollbar is enabled.
when I scroll down after the 4 rows I can see an empty space. I have
handled this problem using scroll event, but when I add another row I
can again see an empty space. Could anyone please tell how to handle
this so that I dont see the empty space.
 
M

Manish

Hi,

You can put the Grid in the div tag and set the Overflow:auto.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div id='div1' runat="server" style="width:347px; height:195px;
overflow:auto; z-index: 100; left: 37px; position: absolute; top: 62px;">
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2"
DataKeyNames="ProductID" DataSourceID="SqlDataSource1"
Height="95px" Width="247px">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName"
HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="SupplierID"
HeaderText="SupplierID" SortExpression="SupplierID" />
<asp:BoundField DataField="CategoryID"
HeaderText="CategoryID" SortExpression="CategoryID" />
</Columns>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True"
ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID],
[CategoryID] FROM [Alphabetical list of products]">
</asp:SqlDataSource>

</div>
</form>
</body>
</html>

Regards,
Manish

www.ComponentOne.com
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top